Java Reference
In-Depth Information
JSTL's Expression Language is distinguished from the other JSP syntax by the limits on
what it can do. There are no assignment operators or conditional logic, which forces
developers to use external Java classes and JSTL actions for these tasks.
Though some Java programmers might blanch at the thought of learning another lan-
guage simply for web applications, the Expression Language is simple enough to be
picked up quickly, especially by those who are comfortable with JavaScript.
By keeping Java code out of JSP pages, the Expression Language offers reusability and
reliability. In conjunction with JSTL, it brings JSP much closer to the promise of separat-
ing the presentation of a web application from the code required to make it happen.
JSTL serves as a nice complementary offering to Struts, an open source web application
framework that's also the work of the Apache Jakarta project.
Programmers who have embraced the model-view-controller philos-
ophy embodied by Struts might question JSTL's inclusion of data-
base actions that don't belong in an application's presentation
layer.
For anything but trivial web applications, programmers should con-
sider putting database access behavior in classes accessed from
JSP rather than using JSTL's SQL actions.
CAUTION
Summary
At this point, you now have three different ways to use the Java language on the web:
applets, servlets, and JSP.
The main purpose of the classes in the javax.servlet and javax.servlet.http pack-
ages is to exchange information with a web server. Java servlets are an alternative to the
CGI, the most popular way that programming languages are used to retrieve and present
data on the Web.
Because servlets can use all features of the Java language with the exception of a graphi-
cal user interface, you can use them to create sophisticated web applications.
JSP pages are an effective way to separate static content on web pages from the dynamic
content generated by servlets for those pages. By using expressions, statements, and dec-
larations, you can write Java programs on pages without ever needing to compile a pro-
gram, lay it out on a web page, design an interface, or publish class files.
 
Search WWH ::




Custom Search