Session Timeout

More than thousands of user uses the web application and each user has unique HttpSession object and consume memory on the serverside . And each user has identified by HttpServletRequest object, that accesses the web application will have a unique HttpSession objects associated. Some time many user uses the same web application, but long of time users inactive and in this situtation session timeout specified.
Lets an example, if an application has capacity 1,00,000 active user at a time , the container create 1,00,000 HttpSession object. And each object has a certain time period for each user active. If any user inactive a given time period then session timeout for that user.
Create Session Timeout
Session timeout can be specified in two ways:
  • In servlet program using setMaxInactiveInterval() method on the HttpSession object. Timeout intervla will be specified in second.
  • Creating a <session-timeout> element in deployment descriptor. Timeout interval will be specified in minutes.
web.xml
<?xml version="1.0" encoding="UTF-8"?> <web-app id="WebApp_ID" version="2.5"> ... <servlet> <servlet-name>FirstServlet</servlet-name> <servlet-class>FirstServlet</servlet-class> </servlet> <servlet> <servlet-name>SecondServlet</servlet-name> <servlet-class>SecondServlet</servlet-class> </servlet> <session-config> <session-timeout> 20 </session-timeout> </session-config> ... </web-app>
 



 

Latest Tutorial


Most Visited Tutorial