vicker313 tech blog

October 3, 2010

How to set Unlimited Session Timeout in Tomcat

Filed under: Tomcat — Tags: , , — vicker313 @ 8:25 am

Session Timeout in Tomcat is set at web.xml, either at Server Level ($TOMCAT/config/web.xml) or Web App Level ($TOMCAT/webapps/yourwebapp/WEB-INF/web.xml). Look for the following tag (or add in):

<session-config>
<session-timeout>60</session-timeout>
</session-config>

The number in session-timeout tag is in minutes. To make it unlimited or no time out, simply set the number to -1 and restart your Tomcat Service.

<session-config>
<session-timeout>-1</session-timeout>
</session-config>

Advertisements

February 14, 2010

Redirect from HTTP to HTTPS in Tomcat

Filed under: Tomcat — Tags: , , , — vicker313 @ 9:09 am

Simple method to configure Tomcat (the version I try is Tomcat 6) so that all HTTP access will redirect to HTTPS.

Edit [TOMCAT_HOME]\webapps\ROOT\WEB-INF\web.xml, add the following codes inside the web-app tag (or just the above of </web-app>).
<security-constraint>
<web-resource-collection>
<web-resource-name>Automatic SSL Forwarding</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>

Create a free website or blog at WordPress.com.