The Java Developers Almanac 1.4


Order this book from Amazon.

   
Home > List of Packages > javax.servlet.jsp  [18 examples] > Java Server Pages  [7 examples]

e1052. Preventing the Creation of a Session in a JSP Page

By default, a JSP page will automatically create a session for the request if one does not exist. However, sessions consume resources and if it is not necessary to maintain a session, one should not be created. For example, a marketing campaign may suggest the reader visit a web page for more information. If it is anticipated that a lot of traffic will hit that page, you may want to optimize the load on the machine by not creating useless sessions.

The page directive is used to prevent a JSP page from automatically creating a session:

    <%-- Prevent the creation of a session --%>
    <%@ page session="false">
    
    <html>
    <head><title>A Session-less JSP Page</title></head>
    <body>
    ...
    </body>
    </html>

 Related Examples
e1046. The Quintessential JSP Page
e1047. Running Java Code in a JSP Page
e1048. Saving Data in a JSP Page
e1049. Implementing a Form in a JSP Page
e1050. Implementing a Form That Prevents Duplicate Submissions in a JSP Page
e1051. Precompiling a JSP Page

See also: Java Server Pages Headers    Java Server Pages Input    Java Server Pages Output   


© 2002 Addison-Wesley.