Re: JSP vs. Servlets
"Sathyaish" <sathya...@gmail.com> wrote:
What are the pros and cons of using servlets instead of JSPs?
senior wrote:
http://www.devx.com/tips/Tip/25217
Broadly speaking, JSPs are for the layout, or "view" aspect of an application,
and servlets are for the context and navigation, or "controller" aspect of an
application.
As the referenced tip suggests, JSPs look like HTML and servlets look like
Java. It is more natural in a JSP to concentrate on artifacts like drop-down
lists, submit buttons, headlines and the like. It is more natural in a servlet
to concentrate on things like parsing a request for its parameters, forwarding
the parameters to business and data logic, managing resource services,
coordinating processes and forwarding the view to the next JSP.
Both aspects of an application are required. Ideally, they will almost fully
separate concerns. You should nearly never have scriptlet (Java code) in a JSP
source file, nor response.out writes in a servlet .java source file.
Check around for the "model-view-controller" (MVC) application model, what Sun
calls the "Model 2 Architecture". It applies to Swing apps and other domains
besides Web apps. It ties in with service architectures and portals, even.
- Lew