File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Default session timeout Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Default session timeout" Watch "Default session timeout" New topic
Author

Default session timeout

Haris Karameh
Ranch Hand

Joined: Oct 17, 2002
Posts: 38
Is there an easy way to get a default httpsession timeout value inside init().
As begginer I have a several ideas how to do it but they are not simple.
TIA Haris
Travis Hein
Ranch Hand

Joined: Jun 06, 2006
Posts: 161
inside of init() in a servlet?

The easiest way would be to define an init parameter for your servlet in the web.xml:
<servlet>
<servlet-name>MyServlet</servlet-name>
<servlet-class>package.to.MyServlet</servlet-class>
<init-param>
<param-name>defaultSessionTimeout</param-name>
<param-value>60</param-value>
</init-param>
</servlet>

You would maintain this value to be the same value as the default session timeout (later on in web.xml):
<session-config>
<!-- the time in minutes -->
<session-timeout>60</session-timeout>
</session-config>


Then your servlet would read the value of the its init parameter:
public void init(ServletConfig config)
throws ServletException {
int defaultTimeout = 60; // our default we use when no init parameter;
try {
defaultTimeout = Integer.parseInt(config.getInitParameter("defaultSessionTimeout");
} catch (NumberFormatException ex) { /* empty */ }

// other init related stuff
}


Error: Keyboard not attached. Press F1 to continue.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Default session timeout