Introduction to Servlets
Servlets vs. CGI
Common Gateway Interface (CGI) was the dominant interface for extending
web servers for
years. Because CGI support was built into every web server on the
market, CGI was a great
choice for development tools and applications that could add dynamic
capabilities to a web
site. CGI languages included C, C++, and Perl, with Perl being the
dominant CGI language.
Enter Java. A networked language from the ground up, Java was written
specifically to take
advantage of the Internet. With built-in support for network sockets,
database connectivity,
string manipulation, and a host of other features, Java quickly became
adopted by developers
all over the world as the premier development language. Nevertheless,
using Java as a CGI
language was still a problem. Most solutions involved creating a new
JVM for each request.
Much like the Perl interpreter, it was necessary to create a new
process for every request to the
program.
The Java Servlet API was introduced as a means of standardizing the use
of Java when used
through a web server. Servlets are, in fact, a complete replacement for
CGI. Servlets offer
many added benefits to the developer, including ease of development,
automatic garbage
collection, fast throughput and response, inter-servlet communications,
and all of the features
inherent in Java.
One of the main problems with traditional CGI applications is
performance. A new process is
created each time a CGI application is requested by the client. This
behavior can lead to
performance problems at popular web sites that handle requests from
multiple users. Servlets,
on the other hand, handle this process more efficiently. The first time
that a servlet is
requested, it is loaded into the web server’s memory space. Subsequent
client requests for the
servlet result in calls to the servlet instance in memory. Also,
servlets can use threading to
process multiple requests efficiently if the JVM embedded in the web
server offers thread
support, whereas CGI programs are not threaded.
Another benefit of servlets over CGI is that servlets are
platform-independent, whereas CGI
programs are platform-dependent. In addition, a servlet maintains
memory of its state once it
is loaded by the server. The JVM running on the web server loads the
servlet when it is called.
CGI programs are stateless because they result in the creation of a new
process each time that
a request is serviced.
__________________________________________________
Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.
http://im.yahoo.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to