Java Reference
In-Depth Information
Movement to Server-Side Java
When the Java language was first introduced by Sun Microsystems Inc., its purpose was to
embed greater interactivity into Web pages. Java has accomplished this through the use of
applets . Applets add functionality to Web pages, but because of compatibility and bandwidth
issues, businesses have started moving to server-side Java.
Java applets are programs that are embedded directly into Web pages. When a browser loads a
Web page, which contains a reference to an applet, the applet byte-code is downloaded to the
client computer and executed by the browser. This is fine for very thin clients, but as applets
grow in size the download times become unacceptable. Applets also have compatibility prob-
lems. To run an applet you must have a compatible browser. If your customer does not have a
compatible browser, applets will not be presented with the proper content. These issues have
forced businesses to take a look at server-side Java.
Server-side Java solves the problems that applets face. When the code is being executed on the
server side, no issues arise with browser compatibility or long download times. The Java appli-
cation on the server only sends the client small packets of information, including HTML,
WML, XML, and so on, that it can understand. Java servlets are one of the options for server-
side Java development.
Definition of a Java Servlet
Servlets are generic extensions to Java-enabled servers. Their most common use is to extend
Web servers, providing a very secure, portable, and easy-to-use replacement for CGI. A servlet
is a dynamically loaded module that services requests from a Web server. It runs entirely inside
the Java Virtual Machine. Because the servlet is running on the server side, it does not depend
on browser compatibility. Figure 2.1 graphically depicts the execution of a Java servlet.
Request
Servlet
Response
Web Browser
Web Server
F IGURE 2.1
Execution of a Java Servlet.
Practical Applications for Java Servlets
Servlets can be used for any number of Web-related applications. After you start using servlets,
you will find more practical applications for them. The following are three examples that I
believe are some of the most important:
Search WWH ::




Custom Search