[ Team LiB ] Previous Section Next Section

Web Applications and Request-Response Model

One of the most important concepts for understanding Web applications is to know how the client's request is processed and how responses are produced as the client needs it. When we covered the important components of the Web application earlier in the chapter, we learned that the J2EE platform provides multiple flavors of servlets to cater to different protocols. One of the most popular and widely used servlet types in the Web application model is based on the HTTP protocol. The Servlet specification provides the necessary infrastructure in terms of APIs and other services for implementing this type of servlet. We'll use this servlet type to understand the request-response model as implemented for Web applications and different parties involved in making this client-server conversation happen. We don't have to know much about the classes and APIs that make up the servlet infrastructure at this time. We'll go into that when we get to Chapter 14, “Writing WebLogic Server Servlets.”

The different parties involved in the HTTP-based request response model are as follows:

  • The Web browser that provides the runtime environment for the Web client

  • The Web server that listens to the incoming requests from different clients and also has the responsibility of serving some static resources, such as HTML pages

  • The application server with a Web container built into it

  • The Web applications that include components as described in Figure 6.2

Figure 6.3 describes the entire request-response cycle in HTTP-based servlets. With the help of Figure 6.3, let's look at the steps involved.

  • The Web browser sends the client request to the Web server.

  • The Web server sorts out the requests, identifies the ones that have to be serviced by a business Web application, and passes them on to the Web container. The Web server itself services some other requests by delivering some static resources, such as HTML pages, to the client.

  • The Web container determines the Web component to invoke based on the deployment information and the input request. The Web component invoked may be a servlet, JSP, or a static resource.

  • The Web container passes objects that map to the Web client request and response streams for use by the invoked component. The request stream is used to get the parameters from the user, and the response stream is used to pass the formatted response back to the client.

Figure 6.3. Request-response model.

graphics/06fig03.gif

The Web server and the application server containing the Web applications need not be different processes. In the case of WebLogic Server, it serves as the Web server and as a J2EE-compliant application server with a built-in Web and EJB container, among other features. The Web browser is the most common client for Web applications, but the user is free to access the Web applications from other client types, including PDA, mobile, and so on. The Web application component should be enabled to deliver the response according to the client that sent the request.

    [ Team LiB ] Previous Section Next Section