Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

servlet vs. jsp page. When to use? 1

Status
Not open for further replies.

vasah20

Programmer
Feb 16, 2001
559
US
Ok - I've got a bit of a question:

Is there a general rule as to when one should use a JSP page or servlet? I mean - if JSP pages eventually end up as compiled code anyways, then why even go the route of using a servlet?

The only real difference I see between the two is that you can explicitly control behaviors via the doPost | doGet methods, but other than that they seem pretty similar.

Can anyone help me or direct me to a site that'll clear this up for me?

TIA leo

------------
Leo Mendoza
lmendoza-at-garbersoft-dot-net
 
You can use a JSP page for things where you want to be able to better control what the page looks like. Plus in a true MVC environment, you need to use JSP for the presentation layer. Mike Wills
AS400 Programmer
[pc2]

Please, if you find my post useful, let me know. [thumbsup2]
 
Vasah20

Here is a few things to bare in mind while you weight in the usage of JSP vs. Servlets in your application design considerations. The idea behind a client side scripting language is to use it to perform clien-side processing, mainly data presentations and views and as thin as possible without clutering the script.

Same goes with JSP, which allows you to combine Java syntax with HTML to produce an output page. The key is to use JSP to generate presentation views of your data, and Servlets on the server side to perform and process business/application logic. As your business rule changes, you change the Servlet to adopt to those business requirements and changes. Business rule and your Servlet functionality kind of evolove together. As per the post by the previous writer. The Model-View-Controller design pattern is the model you should consider adopting while developing JSP and Servlet applications. There are enormous benefits to abstracting your application flow as such, maintenance for one is the most noticeable one.

Hope this helps,
Codelesscode
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top