Showing posts with label J2EE. Show all posts
Showing posts with label J2EE. Show all posts

Tuesday, September 19, 2017

Tomcat: Application session timeout


To set the session timeout for the Tomcat web application, call HttpSession.setMaxInactiveInterval(int interval) -- interval is the idle time in seconds before timeout. e.g. HttpSession.setMaxInactiveInterval(30) times out the session if it is idle more than 30 seconds.

If the above method is not call in the application, the session-timeout configuration in the application's web.xml defines the timeout in minutes. e.g. WEB-INF/web.xml:
    <session-config>
          <session-timeout>1</session-timeout>
    </session-config>
The above configuration times out the session after 1 minute.

If the session-timeout is not set in the application's web.xml, it is defined in TOMCAT_HOME/conf/web.xml:
    <session-config>
          <session-timeout>30</session-timeout>
    </session-config>

Sunday, August 6, 2017

J2EE: custom error page


If a custom error page for a specific HTTP error is needed:

1. Add the error page configuration in the web application's WEB-INF/web.xml:
     <error-page>
        <error-code>404</error-code>
        <location>/error404.html</location>
    </error-page>


2. Create a error404.html at the web application's root directory.

If such configuration is not set in the web application but somehow the 404 error can still trigger a custom error page, that may be because the administrator has done it for you in the Tomcat's conf/web.xml.


 
Get This <