A JSP page describes how to create a response object from a request object for a given protocol, possibly creating and/or using some other objects. A JSP page is executed by a JSP container; requests sent to a JSP page are delivered by the JSP container to some JSP page implementation instance that is a subclass of servlet (see Chapter JSP.3). JSP.2.5.1 Web ApplicationsA web application is a collection of resources that are available through some URLs. The resources include JSP pages, Java servlet classes, static pages, and other Java technology-based resources and classes to be used at the server-side as well as Java resources and classes (like applets, JavaBeans components , and others) which are to be downloaded for use by the client. A web application is described in more detail in Chapter SRV.9 of the Servlet 2.2 specification. A web application contains a deployment descriptor web.xml that contains information about the JSP pages, servlets, and other resources used in the web application. The deployment descriptor is described in detail in Chapter SRV.13 of the Servlet 2.2 specification. JSP 1.1 requires that all these resources are to be implicitly associated with and accessible through a unique ServletContext instance, which is available as the application implicit object (Section JSP.2.8). The JSP specification inherits the notions of a web application from the Servlet 2.2 specification. The application to which a JSP page belongs is reflected in the application object and has impact on the semantics of the following elements:
JSP.2.5.2 Relative URL Specifications Within an ApplicationElements may use relative URL specifications , which are called "URI paths" in the Servlet 2.1 specification. These paths are as in RFC 2396 specification, i.e., only the path part, no scheme or authority. Some examples are: "myErrorPage.jsp" "/errorPages/SyntacticError.jsp" "/templates/CopyrightTemplate.html" When such a path starts with a "/", it is to be interpreted by the application to which the JSP page belongs; i.e., its ServletContext object provides the base context URL. We call these paths "context-relative paths." When such a path does not start with a "/", it is to be interpreted relative to the current JSP page: the current page is denoted by some path starting with "/" which is then modified by the new specification to produce a new path that starts with "/"; this final path is the one interpreted through the ServletContext object. We call these paths "page-relative paths." The JSP specification uniformly interprets all these paths in the context of the web server where the JSP page is deployed; i.e., the specification goes through a map translation. The semantics applies to translation-time phase (i.e., include directives, Section JSP.2.7.6), and to request-time phase (i.e., to include, Section JSP.2.13.4, and forward, Section JSP.2.13.5, actions). If a specific tool can ascertain by some mechanism the status of the URL to resource maps at deployment time, the tool can take advantage of this information. With the appropriate assertions, the translation phase might be performed before deploying the JSP page into the JSP container. JSP.2.5.3 Web Containers and Web ComponentsA JSP container is a system-level entity that provides life-cycle management and runtime support for JSP pages and servlet components. The term web container is synonymous with JSP container. A web component is either a servlet or a JSP page. A web component may use the services of its container. The servlet element in a web.xml deployment descriptor is used to describe both types of web components; note that most JSP page components are defined implicitly in the deployment descriptor through the use of an implicit .jsp extension mapping. JSP.2.5.4 JSP PagesA JSP page implementation class defines a jspService() method mapping from the request to the response object. Some details of this transformation are specific to the scripting language used; see Chapter JSP.4. Most details are not language specific and are described in this chapter. Most of the content of a JSP page is devoted to describing what data is written into the output stream of the response (usually sent back to the client). The description is based on a JspWriter object that is exposed through the implicit object out (see Section JSP.2.8, "Implicit Objects"). Its value varies:
A JSP page can also describe what should happen when some specific events occur. In JSP 1.1, the only events that can be described are initialization and destruction of the page; these are described using "well-known method names " in declaration elements (see Section JSP.3.1.2). Future specifications will likely define more events as well as a more structured mechanism for describing the actions to take. |