Java offers two primary advantages over traditional server-based languages, which has made the technology much sought after. First, Java is inherently object-oriented and has a rich set of classes and methods for all purposes. Second, Java is platform-independent, meaning that it runs on many different platforms with only a single code base. The ability of Java to run on any platform makes easy the deploy applications using Java technology on almost any underlying operating system that supports Java.
Over the past few years, Java Web technology has evolved as Java Servlets, Java Server Pages (JSP), JavaBeans, and many other Java-driven components. Initially Sun presented its own framework in the form of Java Web Server, which was capable of running several Java technologies and became very popular in the application server market. Some of the early adopters of this framework were IBM with WebSphere, BEA with WebLogic, and Allaire with JRun. As the platform became popular, more Java application servers were introduced. Some of the more popular ones are Jserv and Tomcat, which are open-source and run with Apache, iPlanet, Resin, Servertec, and Enhydra (among others).
The smallest building block of Java application servers is the servlet. As shown in Figure 12-1, servlets reside on the server in the pool of threads. They are precompiled and have access to all internal server resources. Every request made to the application server is received by a servlet in its own thread. Such an architecture provides enormous scalability for Web applications.
As shown in Figure 12-2, the core servlet layer has many servlets, including file, JSP, and server side includes (SSI). These servlets are extended by HTTPservlet to serve the HTTP protocol. Servlets such as FileServlet give access to HTML/TEXT files. Each GET request to simple text files is handled by this servlet with a simple thread, and the file is transmitted back to the client. Any request to JSP files is handled by the JSPServlet invoker, which is supported by Java compiler and runtime libraries. Java server pages are compiled and converted to reusable classes.