About the Sessions in servlets
2 posts in topic
Flat View  Flat View

Posted By:   ASHOK_REDDY
Posted On:   Friday, January 20, 2006 12:52 AM

When will a Session get created and when it will be destroyed.We can create the Sessions or the container will create it for us.

Re: About the Sessions in servlets

Posted By:   Rajesh_Pandey  
Posted On:   Thursday, January 26, 2006 03:00 AM


In servlet you have to declare httpSession sessionname=req.getSession(true).But in jsp in is default.other conrole regarding session can be handle through implecite method define in servlet or jsp.

Rajesh Pandey J2ee Developer

Re: About the Sessions in servlets

Posted By:   Anonymous  
Posted On:   Friday, January 20, 2006 02:24 AM

Sessions are created when you call request.getSession() or request.getSession(true) in your Servlet (provided an existing Session doesn't already exist -- otherwise the existing one would just be returned). One caveat is that the container automatically creates sessions when JSP pages are used, unless you specify session="false" in the page header. But without JSPs, the container will not create a Session for you.

Sessions are destroyed when they timeout or when you call invalidate() on them. The timeout period is up to the container. By default, Tomcat times out sessions in 30 minutes. But you can override this setting in web.xml with something like this:




Jon Emerson

About | Sitemap | Contact