On 12/20/2000 at 5:39 PM Rui Oliveira wrote:
> can someone tell me which one is best: JSP or [regular] Servlets?
All JSPs are actually servlets, and the JSP file is really just another
way to Java source. The container (or one of its helpers) compiles
them into servlets as needed, and then executes that servlet. JSP is a
Rapid Application Development tool for writing servlets that display
page views. If you have used any JSPs in your Tomcat installation, you
can check the (default) "work" directory for the java source and class
files is being auto-generated for the JSPs.
There are some performance drawbacks to JSPs, which may or may not make
an actual difference in your applicaton. The first drawback is that
containers always check the edit date of a JSP to see if it needs to be
recompiled before it runs the associated servlet. Of course, this must
be slower than running the servlet outright, but your users may never
notice the difference. Once the design is stable, it is also possible
to compile your JSPs into conventional servlets, if you need that extra
boost. As mentioned elsewhere, there may also be ways you can
performance-tune a servlet by hand that are not available in JSP.
The major benefit is rapid development. JSPs can be a lot easier to
write and maintain than an ordinary servlet. Frameworks that leverage
JSPs in a Model View Controller architecture (like Jakara Struts) are
also becoming available. This can make your applicaiton much easier to
use by other developers, or in a team environment where different
people handle different parts of the application.
Of course, your application would probably still use ordinary servlets
for various other tasks, even if it uses JSP to create most of the page
views.
-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel 716 425-0252; Fax 716 223-2506.
-- http://www.husted.com/