Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 233
  • Last Modified:

session expires

Hi,

I have configured session value as "-1" so that in my application session never expires?
But if i access my page within the application after few hours and get value from session like
request.getSession.getAttribute("ID")

It throws null pointer exception? what can be the cause and why it is throwing null pointer when the session should never expire as per web.xml?
0
Rocking
Asked:
Rocking
  • 3
1 Solution
 
rrzCommented:
Are you using Tomcat? If yes, then is it stand alone? Or is Apache web server in front of it?
0
 
RockingAuthor Commented:
Yes, tomcat only configured through eclipse
0
 
rrzCommented:
I am testing with stand alone Tomcat on my desktop. My initial test passed. It lasted an hour. Tomorrow I will try for a longer period. Here is my test JSP.
<%@ page import="java.util.Date" %>
<%
   if(session.isNew())session.setMaxInactiveInterval(-1);
   long now = new Date().getTime();
   long last = session.getLastAccessedTime();
   long inactivePeriod = (now - last)/60000;
%>
The MaxInactiveInterval is ${pageContext.session.maxInactiveInterval}<br/>
Is the requested session ID still valid? ${pageContext.request.requestedSessionIdValid}<br/>
Inactive period was <%=inactivePeriod%> minutes <br/>
The session id is ${pageContext.session.id}<br/>

Open in new window

0
 
rrzCommented:
I tested again with the code I posted. The session seems to last.  I waited for 132 minutes with no problem.
0
 
Mayank SAssociate Director - Product EngineeringCommented:
Why do you want the session to never expire? That's like a memory leak and over a prolonged duration the application will bomb and give an OutOfMemoryError
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now