Web Development with JavaServer Pages

Скачать в pdf «Web Development with JavaServer Pages»

While we will not cover topics such as these in-depth, there are three more deployment descriptor tags we will discuss. First, we will see how the <session-config> tag may be used to control the behavior of sessions created by an application. Second is the use of the <context-param> tag to specify initialization parameters for the application as a whole. Finally, it is the <error-page> tag, which can be used to indicate specific URLs to which control should be transferred when various types of errors occur.

The <session-config> tag is used to specify a default time-out value for sessions created by the application’s servlets and JSP pages, via its single required subelement, the <session-timeout> tag. The body of <session-timeout> should be an integral value indicating how many minutes of inactivity are required before a session is considered to have expired, as in the following example:






In this case, the application’s sessions are set to expire, by default, after half an hour of inactivity. This default value can be explicitly overridden for individual sessions by means of the setMaxInactiveInterval() method of the javax.serv-let.http.HttpSession interface. At most one <session-config> element may appear in a web.xml application descriptor. Note that a value of zero or less in the body of the <session-timeout> tag indicates to the JSP container that, by default, sessions should never time-out. In such a case, the setMaxInactiveInterval () method should be used to set the expiration period programmatically, or the application should itself take care of keeping track of and invalidating sessions. Otherwise, the container will keep accumulating sessions that never expire until it runs out of memory.

Скачать в pdf «Web Development with JavaServer Pages»