How to implement session timeout in Portal / J2EE applications?

0 comments

Configuring IBM WebSphere Portal with no session timeout can cause memory growth problems because of the accumulation of HTTP sessions that live forever in the Java heap.

Resolving the problem

It is always better to configure a finite session timeout in order to control memory usage of session management.
For example, set the session timeout to 30 minutes (default value). After testing this value according to you application needs, you may increase or decrease it in order to better customize the user experience on Portal.

Another easiest way to implement the session timeout in J2EE applications is by using the HTML Meta tags.


If you are working on Portal application then you can place the same code in Portal theme default.jsp

Test_Expiry_Session.jsp

<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
<meta http-equiv="refresh" content="<%= session.getMaxInactiveInterval() %>;url=Test_Login.jsp">
</head>
<body>
<h1>Hello, Portal User</h1>
Your session is about to expire in <%= session.getMaxInactiveInterval() %> seconds.<br/>
Thank you!
</body>
</html>

Test_Login.jsp

<%@page contentType="text/html"%><%@page pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title>
</head>
<body>
<h1>You session has timed out. Please login again</h1>
</body>
</html>

No comments:

Post a Comment

Recent Posts

Reader Comments

Popular Posts

© 2011-2013 Web Portal Club