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>

Comments

26 Oct 2010 - 5:51am by Anonymous (not verified)

test

26 Oct 2010 - 5:51am by Anonymous (not verified)

test

30 May 2011 - 12:03am by Jan Burse (not verified)

The following is wrong:
<%@page session="false">

It should read:
<%@page session="false"%>

Note the % sign at the end.

20 Aug 2011 - 1:43pm by Some guy (not verified)

What you have put is not clear and hence maybe wrong.

There is no guaranteed way to prevent the CREATION of a session when a JSP page is run. It depends on how the container handles it - try the page directive you have in Tomcat5.5 and it still will create a session.

There is a guaranteed way to prevent the ACCESS to session in a JSP page and the page directive you have will ensure that the JSP doesn't have a 'session' reference to it, the session still may get created based on the container and it is unclear whether that is a violation of JSP spec 2.0 conformity.

22 Nov 2011 - 10:20pm by buy spyder jacket (not verified)

Last time I have given you some suggestion, today I will tell you some others. Please remember to take action when you read them. If you also think they are very good, you can also tell your friends. I want all the Canada goose jackets lovers can share their ideas together.
Like cleaning of the spyder prevail jacket, the goose jacket also need some special detergent. The down jackets are made of poultry feather protein fiber which will lose the soft luster and the elasticity and become hard and dry if you use the soap or detergent cleaning (not to use washing powder with enzyme), because it has a strong alkaline. If you have carelessly using the alkaline detergent, the residual detergent will leave some white traces in the surface of the goose jacket. There is also a way to remove them, that is, first rinse them for two times, then, add two spoonful of vinegar in the warm water, the canada goose parka should be soaked for a while then rinsed, because the vinegar can neutralize alkaline detergent.

Post a comment

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image. Ignore spaces and be careful about upper and lower case.