Why Use JSP?
In the early days of the Web, the Common Gateway Interface (CGI) was the only tool for developing dynamic web content. However, CGI is not an efficient solution. For every request that comes in, the web server has to create a new operating system process, load an interpreter and a script, execute the script, and then tear it all down again. This is very taxing for the server and doesn’t scale well when the amount of traffic increases.
Numerous CGI alternatives and enhancements, such as
FastCGI,
mod_ perl
from Apache, NSAPI from Netscape,
ISAPI
from Microsoft, and
Java Servlets from Sun Microsystems,
have been created over the years. While these solutions offer better
performance and scalability, all of these technologies suffer from a
common problem: they generate web pages by embedding
HTML directly in programming
language code. This pushes the creation of dynamic web pages
exclusively into the realm of programmers. JavaServer Pages, however,
changes all that.
Embedding Elements in HTML Pages
JSP tackles the problem from the other direction. Instead of embedding HTML in programming code, JSP lets you embed specialized code (sometimes called scripting code) into HTML pages. Java is the default scripting language of JSP, but the JSP specification allows for other languages as well, such as JavaScript, Perl, and VBScript. We will begin looking at all the JSP elements in detail later, but at this point let’s introduce you to a simple JSP page:
<html> <body bgcolor="white"> ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access