{"id":1460,"date":"2011-02-07T22:35:50","date_gmt":"2011-02-07T17:05:50","guid":{"rendered":"http:\/\/JitendraZaa.com\/blog\/?p=1460"},"modified":"2011-02-07T22:35:50","modified_gmt":"2011-02-07T17:05:50","slug":"setting-session-timeout-in-jsp-servlet","status":"publish","type":"post","link":"https:\/\/www.jitendrazaa.com\/blog\/java\/jsp\/setting-session-timeout-in-jsp-servlet\/","title":{"rendered":"Setting Session Timeout in JSP Servlet"},"content":{"rendered":"<p>Session can die in following three ways in J2EE application:<\/p>\n<ol>\n<li>Its Time out<\/li>\n<li>invalidate() method called on Session Object<\/li>\n<li>Application goes down (Application crashes or undeployed)<\/li>\n<\/ol>\n<p><!--more--><\/p>\n<p><strong>Method 1: Configuring session timeout in the DD<\/strong><\/p>\n<p>Session Time out can be configured in <strong>DD <\/strong>(Deployment Descriptor \/ web.xml) and it has virtually same effect as calling <strong>setMaxInactiveInterval()<\/strong> on every session that is created :<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n&lt;web-app&gt;\n...\n&lt;servlet&gt;\n....\n&lt;\/servlet&gt;\n&lt;session-config&gt;\n    &lt;session-timeout&gt;15&lt;session-timeout&gt;\n&lt;\/session-config&gt;\n&lt;\/web-app&gt;\n<\/pre>\n<p><strong><span style=\"text-decoration: underline;\"> Note :<\/span> <\/strong>Argument in tag  is in minutes. In above example its 15 minutes.<\/p>\n<p><strong>Method 2: \u00a0Setting Session timeout for the specific session object<\/strong><\/p>\n<p>If you want to change the session timeout for any particular session then we can call below method on that Session :<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\nsession.setMaxInactiveInterval(30*60);\n<\/pre>\n<p><strong><span style=\"text-decoration: underline;\"> Note :<\/span><\/strong> the argument passed in method setMaxInactiveInterval() is in seconds. In Above example its 30 minutes.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to set the Session Time out in JSP and Servlet<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"jz_research_post":"","_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4,11],"tags":[125],"class_list":["post-1460","post","type-post","status-publish","format-standard","hentry","category-jsp","category-servlet","tag-j2ee"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":1643,"url":"https:\/\/www.jitendrazaa.com\/blog\/java\/jsp\/servlet-hibernate-jquery-and-ajax-based-google-like-chat\/","url_meta":{"origin":1460,"position":0},"title":"Servlet, Hibernate, jQuery and Ajax based google like chat","author":"Jitendra","date":"March 14, 2011","format":false,"excerpt":"Servlet, Hibernate, jQuery and Ajax based google like chat with source code","rel":"","context":"In &quot;Hibernate&quot;","block_context":{"text":"Hibernate","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/java\/hibernate\/"},"img":{"alt_text":"Servlet, Hibernate, jQuery and Ajax based google like chat","src":"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2011\/03\/Servlet-Hibernate-jQuery-and-Ajax-based-google-like-chat.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1155,"url":"https:\/\/www.jitendrazaa.com\/blog\/microsoft\/net\/set-session-timeout-in-iis-internet-information-services\/","url_meta":{"origin":1460,"position":1},"title":"Set Session Timeout in IIS (Internet Information Services)","author":"Jitendra","date":"September 28, 2010","format":false,"excerpt":"Step by step description to set the Session.Timeout in IIS(Internet Information Services) Server for ASP.NET","rel":"","context":"In &quot;ASP.NET&quot;","block_context":{"text":"ASP.NET","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/microsoft\/net\/"},"img":{"alt_text":"IIS Website Properties","src":"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2010\/09\/IIS-Website-Properties-300x297.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1976,"url":"https:\/\/www.jitendrazaa.com\/blog\/java\/jsp\/j2ee-servlet-jsp-jsf-and-jms-version-table\/","url_meta":{"origin":1460,"position":2},"title":"J2EE &#8211; Servlet , JSP , JSF and JMS Version Table","author":"Jitendra","date":"April 13, 2011","format":false,"excerpt":"J2EE - Servlet , JSP , JSF and JMS Version Table","rel":"","context":"In &quot;JSP&quot;","block_context":{"text":"JSP","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/java\/jsp\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1479,"url":"https:\/\/www.jitendrazaa.com\/blog\/java\/servlet\/example-to-override-the-init-method-of-the-servlet\/","url_meta":{"origin":1460,"position":3},"title":"Example to Override the init() method of the servlet","author":"Jitendra","date":"February 11, 2011","format":false,"excerpt":"Example to Override the init() method of the servlet","rel":"","context":"In &quot;Servlet&quot;","block_context":{"text":"Servlet","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/java\/servlet\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1501,"url":"https:\/\/www.jitendrazaa.com\/blog\/java\/servlet\/difference-in-sendredirect-and-requestdispatcher-in-servlet\/","url_meta":{"origin":1460,"position":4},"title":"Difference in SendRedirect() and RequestDispatcher() in Servlet","author":"Jitendra","date":"February 13, 2011","format":false,"excerpt":"difference in SendRedirect() and RequestDispatcher() in Servlet","rel":"","context":"In &quot;Servlet&quot;","block_context":{"text":"Servlet","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/java\/servlet\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1494,"url":"https:\/\/www.jitendrazaa.com\/blog\/java\/servlet\/life-cycle-of-servlet\/","url_meta":{"origin":1460,"position":5},"title":"Life Cycle of Servlet","author":"Jitendra","date":"February 12, 2011","format":false,"excerpt":"Explain Life Cycle of Servlet","rel":"","context":"In &quot;Servlet&quot;","block_context":{"text":"Servlet","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/java\/servlet\/"},"img":{"alt_text":"Servlet Life Cycle","src":"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2011\/02\/Servlet-Life-Cycle.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts\/1460","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/comments?post=1460"}],"version-history":[{"count":0,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts\/1460\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/media?parent=1460"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/categories?post=1460"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/tags?post=1460"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}