Home Jsp Disabling Session in JSP

Related Tutorials


 
 

Share on Google+Share on Google+

Disabling Session in JSP

Advertisement
In this tutorial you will learn how to disable session creation in the JSP pages. Disabling the session in some pages will improve the performance of your JSP container.

Disabling Session in JSP

        

In this tutorial you will learn how to disable session creation in the JSP pages. Disabling the session in some pages will improve the performance of your JSP container.

Every time a JSP is requested, JSP creates an HttpSession object to maintain state for each unique client. The session data is accessible in the JSP as the implicit session object. In JSPs, sessions are enabled by default. 

Session object uses the server resources. Each session object uses up a small amount of system resources as it is stored on the server side. This also increases the traffic as the session ID is sent from server to client. Client also sends the same session ID along with each request. If some of the JSP pages on your web site are getting thousands of hits from internet browser and there is not need to identify the user, so its better to disable the session in that JSP page. 

You can tell the container to disable session in the JSP file by setting the session attribute to false. Set the session attribute of the page directive to false, as shown in the following example: 

<%@ page session="false" %>

Here is the full code of jsp file in which session is disabled:

<%@ page language="java" session="false"%>
<html>
<head>
<title>Session Disabled</title>
</head>
<body>
<p>Session is Disabled in this page
</body>
</html>


Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: March 13, 2008

Related Tutorials

Discuss: Disabling Session in JSP   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:1
Dayanara
January 16, 2012
cVGqKlImVyRpRIqzt

I was looking everywhere and this popped up like nhoting!
DMCA.com