You can find a discussion on web computing here. In this overview, we are to see the dominant role being played by Java in web computing.Web Containers and Web Applications
Web applications are server-side applications. Web applications are collections of web resources, such as servlets, JSPs, HTML pages, etc. A web application is rooted at a specific path in a web server and can be conveniently distributed as a Java Archive (JAR) file with a .war file name extension. For any server-side application development, the following are the most essential requirements. A programming model and an API, server-side runtime support and deployment support.
For developing and running such kinds of applications, the Java 2 Enterprise Edition (J2EE) comes with standard specifications for a set of essential tools and technologies. Firstly, Sun Microsystems introduced Java Servlets and Java Server Pages (JSP), which are the building blocks for developing web applications. Java Servlets and JSP pages are often called as the web components. Secondly, Sun Microsystems came with a concept of web container that is essentially a Java runtime providing an implementation of the Java Servlet API and other facilities for JSP pages. The web container is responsible for initializing, invoking, and managing the life cycle of Java servlets and and Java server pages. Finally, the J2EE specification defines a packaging structure for web application. The specification also defines a deployment descriptor for each web application. The deployment descriptor is an XML file that lets us to customize the web application at deployment time.Web Components
Both Java Servlets and Java Server Pages (JSPs) are referred to as Web components. They enhance the functionality of Web-based applications deployed in application and Web servers. In addition to that, they combine together to design efficient content publishing systems that support separation of presentation and business logic of Web-based applications.
Separating presentation and logic when building server-side Web-based applications allows the Web designers, especially those with less experience in designing application software, to generate Web pages with dynamic content easier and faster. For Web sites with information content that needs to change frequently, this separation process is highly beneficial and helps to bring new information to Web site visitors faster. Earlier Web-based applications, which contain both presentation and business logic clubbed together face maintenance problems. The solution is to use the Model/View/Controller (MVC) paradigm for building user interfaces. With MVC, the back-end system is our Model, the templates for creating the look and feel of the response is the View, and the code that glues it all together is the Controller. Sun introduced two solid technologies for this: Java Servlets and Java Server Pages (JSP). JSPs fit! ! perfectly into this solution as a way of creating a dynamic response or View. Servlets containing logic for managing requests act as the Controller, while the existing business rules are the Model.Deployment Descriptors
Deployment descriptors (DD) are an important part of J2EE web applications. They help in managing the deployment configuration of web applications. For web containers, the deployment deployment is an XML file called web.xml stored in the /WEB-INF directory of the web application. The Java Servlets specification specifies a document type definition (DTD) for the deployment descriptor. A deployment descriptor has several purposes:
1. Initialization of parameters for servlets and web applications - This allows us to minimize the amount of hard coding of initialization values within our web applications. For example, if our servlet requires access to a database, the best place to specify the servlet details including the login and password is the deployment descriptor. This allows us to configure our applications without having to recompile the servlets.
2. Servlet/JSP Definitions - Each servlet/precompiled JSP used in a web application should be defined in the deployment descriptor. This entry includes the name of the servlet or JSP, class of the servlet or JSP, and an optional description.
3. Servlet/JSP Mappings - Web containers use this information to map incoming requests to servlets and JSPs.
4. MIME Types - Since each web application can contain several content types, one can specify the MIME types for each of these in the deployment descriptor.
5. Security - One can manage access control for his application using the deployment descriptor. For example, one can specify which pages of his web application require a login, what the login page should be, and what role the user should have, etc.Structure of Web Applications
A web application has four parts: A public directory, a WEB-INF/web.xml file, a WEB-INF/classes directory and a WEB-INF/lib directory.
The public area is the root of the application, excluding the WEB-INF directory. Here all the HTML files would be kept. The web container can serve any of the files under the public area.
The WEB-INF directory is a private area. The container will not serve contents of this directory to users. The files in this are meant for container use. The contents include the deployment descriptor (web.xml file), a classes directory, and a lib directory. The classes directory is meant for all compiled classes of one's servlets and other utility classes. If his application has packaged JAR files, he can copy such JAR files into the lib library. The container uses these two directories to locate servlet and other dependent classes.Types of Web Containers
There are mainly three types of web containers in the market. They are:
1. web container in a J2EE application server - most of the commercial J2EE application server such as BEA's WebLogic, Borland's Inprise Application Server, Netscape's iPlanet Application Server, IBM's WebSphere Application server, etc. now include web containers built in.
2. Web containers built into web servers - here the web container is integrated with web server. They are Sun's Java WebServer and Jakarta TomCat from Apache project. Both includes a web server along with a web container.
3. Web container in a separate runtime - In this case, web server communicates with web container, which is outside the address space of the web server. The examples include Apache and Microsoft IIS, which require a separate Java runtime to actually run servlets and web server plug-in to integrate the Java runtime with the web server. The plug-in handles communication between the web server and the web container. Commercially available servlet/JSP engines such as Allaire's JRun provide plug-in to integrate with web servers. Thus through plug-ins various web servers can configured to work with containers, which are in separate runtime.
The concept of web containers is simple yet powerful. Web containers allow us to build dynamic web applications using a very simple set of Java Servlet API and JSP pages.
Click for Web Computing