Preface
JavaServer Pages™ (JSP)
is a technology for web application development that has
received a great deal of attention since it was first announced in
1999. Since then, it has gone through three revisions. This book
covers the 2.0 version of the specification.
Why is JSP so exciting? One reason is that JSP is Java-based, and
Java™ is well suited for enterprise computing. In
fact, JSP is a key part of the Java 2™ Enterprise
Edition (J2EE) platform and can take advantage of the many Java
Enterprise™ libraries, such as
JDBC™, JNDI™, and Enterprise
JavaBeans™.
Another reason is that JSP supports a powerful model for developing
web applications that separates presentation from processing.
Understanding why this is so important requires a bit of a history
lesson. In the early days of the Web, the only tool for developing
dynamic web content was the Common Gateway Interface (CGI). CGI
outlined how a web server made user input available to a program, as
well as how the program provided the web server with dynamically
generated content to send back. CGI scripts were typically written in
Perl. (In fact, Perl/CGI scripts still drive numerous dynamic web
sites.) However, CGI is not an efficient solution. For every request,
the web server has to create a new operating-system process, load a
Perl interpreter and the Perl script, execute the script, and then
dispose of it when it's done.
To provide a more efficient solution, various alternatives to CGI
have been added to programmers' toolboxes over the
last few years: FastCGI, for example, runs each CGI program in an
external permanent process (or a pool of processes). In addition,
mod_perl for Apache, NSAPI for Netscape, and ISAPI for
Microsoft's IIS all run server-side programs in the
same process as the web server itself. While these solutions offer
better performance and scalability, each one is supported only by a
subset of the popular web servers.
The Java Servlet API, introduced in
early 1997, provides a solution to the portability issue. However,
all these technologies suffer from a common problem:
HTML code embedded inside programs. If
you've ever looked at the code for a servlet,
you've probably seen endless calls to
out.println( ) that contain scores of HTML tags.
For the individual developer working on a simple web site, this
approach may work fine, but it makes it difficult for people with
different skills to work together to develop a web application.
This embedded HTML code is becoming a significant problem. As web
sites become increasingly complex and more critical to an
organization's success, the appearance and usability
of the web interface becomes paramount. New client technologies, such
as client-side scripts and DHTML, are used to develop more responsive
and interactive user interfaces, stylesheets can make it easier to
globally change fonts and colors, and images make the interface more
appealing. At the same time, server-side code is getting more
complex, and the demands for reliability, performance, and fault
tolerance are increasing. The increasing complexity of web
applications requires a development model that allows people with
different skills to cooperate efficiently.
JSP provides just such a development model, allowing web page authors
with skills in areas such as client-side technologies and usability
to work in tandem with programmers who are experienced in server-side
technologies, such as multithreading, resource pooling, databases,
and caching. While there are other technologies, such as ASP, PHP,
and ColdFusion, that support similar development models, none offer
all the advantages of JSP.
|