Oracle JavaServer Pages Developer's Guide and Reference
Release 8.1.7

Part Number A83726-01

Library

Product

Contents

Index

Go to previous page Go to beginning of chapter Go to next page

Web Application Hierarchy

The entities relating to a Web application (which consists of some combination of servlets and JSP pages) do not follow a simple hierarchy, but can be considered in the following order:

  1. servlet objects (including page implementation objects)

    There is a servlet object for each servlet and for each JSP page implementation in a running application (and possibly more than one object, depending on whether a single-thread or multiple-thread execution model is used). A servlet object processes request objects from a client and sends response objects back to the client. A JSP page, as with servlet code, specifies how to create the response objects.

    You can think of multiple servlet objects as being within a single request object in some circumstances, such as when one page or servlet "includes" or forwards to another.

    A user will typically access multiple servlet objects in the course of a session, with the servlet objects being associated with the session object.

    Servlet objects, as well as page implementation objects, indirectly implement the standard javax.servlet.Servlet interface. For servlets in a Web application, this is accomplished by subclassing the standard javax.servlet.http.HttpServlet abstract class. For JSP page implementation classes, this is accomplished by implementing the standard javax.servlet.jsp.HttpJspPage interface.

  2. request and response objects

    These objects represent the individual HTTP requests and responses that are generated as a user runs an application.

    A user will typically generate multiple requests and receive multiple responses in the course of a session. The request and response objects are not "contained in" the session, but are associated with the session.

    As a request comes in from a client, it is mapped to the appropriate servlet context object (the one associated with the application the client is using) according to the virtual path of the URL. The virtual path will include the root path of the application.

    A request object implements the standard javax.servlet.http.HttpServletRequest interface.

    A response object implements the standard javax.servlet.http.HttpServletResponse interface.

  3. session objects

    Session objects store information about the user for a given session and provide a way to identify a single user across multiple page requests. There is one session object per user.

    There may be multiple users of a servlet or JSP page at any given time, each represented by their own session object. All these session objects, however, are maintained by the servlet context that corresponds to the overall application. In fact, you can think of each session object as representing an instance of the Web application associated with a common servlet context.

    Typically, a session object will sequentially make use of multiple request objects, response objects, and page or servlet objects, and no other session will use the same objects; however, the session object does not "contain" those objects per se.

    A session lifecycle for a given user starts with the first request from that user. It ends when the user session terminates (such as when the user quits the application) or there is a timeout.

    HTTP session objects implement the javax.servlet.http.HttpSession interface.


    Note:

    Prior to the 2.1(b) version of the servlet specification, a session object could span multiple servlet context objects.  


  4. servlet context object

    A servlet context object is associated with a particular path in the server. This is the base path for modules of the application associated with the servlet context, and is referred to as the application root.

    There is a single servlet context object for all sessions of the application in any given JVM, providing information from the server to the servlets and JSP pages that comprise the application. The servlet context object also allows application sessions to share data within a secure environment isolated from other applications.

    The servlet container provides a class that implements the standard javax.servlet.ServletContext interface, instantiates this class the first time a user requests an application, and provides this ServletContext object with the path information for the location of the application.

    The servlet context object typically has a pool of session objects to represent the multiple simultaneous users of the application.

    A servlet context lifecycle starts with the first request (from any user) for the corresponding application. The lifecycle ends only when the server is shut down or otherwise terminated.

    (For additional introductory information about servlet contexts, see "Servlet Contexts".)

  5. servlet configuration object

    The servlet container uses a servlet configuration object to pass information to a servlet when it is initialized--the init() method of the Servlet interface takes a servlet configuration object as input.

    The servlet container provides a class that implements the standard javax.servlet.ServletConfig interface and instantiates it as necessary. Included within the servlet configuration object is a servlet context object (also instantiated by the servlet container).



Go to previous page
Go to beginning of chapter
Go to next page
Oracle
Copyright © 1996-2000, Oracle Corporation.

All Rights Reserved.

Library

Product

Contents

Index