• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

session expire exception

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I am using session in my jsp and fetching userid and name from session in every jsp. if 20 minutes,I do not do any thing on the project after that I start work on it. its gives nullpointerException.

If i login again then again it work finely.

what can i do for handling that type of Exception.
I am using Struts 1.1

I am waiting your response...........

Thanks
Anit Jain
 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Either check userid equality to null in every action, if its null, then redirect the user to login page

OR

use Filter class, which filter out each request as per the session validity !
 
Amit Indore
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I wanti check session expire or not. So i write that code in my Action Class in Struts1.1 but when session is expire it is not sendRedirect from give action mapping.
Its give Error:java.lang.IllegalStateException: Cannot forward after response has been committed.
Code:
//----------------Check session Expire or not--
HttpSession session = request.getSession();
if(session.getAttribute("userinfo")== null)
{ System.out.println("session Expire" );
response.sendRedirect("Index.do");
}
Hi All,

I wanti check session expire or not. So i write that code in my Action Class in Struts1.1 but when session is expire it is not sendRedirect from give action mapping.
Code:
//----------------Check session Expire or not--
HttpSession session = request.getSession();
if(session.getAttribute("userinfo")== null)
{ System.out.println("session Expire" );
response.sendRedirect("Index.do");
}

Its give Error:java.lang.IllegalStateException: Cannot forward after response has been committed.
Sir, help me.What can do?
 
Amit Indore
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I want check session expire or not. So i write that code in my Action Class in Struts1.1 but when session is expire it is not sendRedirect from give action mapping.
Code:
//----------------Check session Expire or not--
HttpSession session = request.getSession();
if(session.getAttribute("userinfo")== null)
{ System.out.println("session Expire" );
response.sendRedirect("Index.do");
}

Its give Error:java.lang.IllegalStateException: Cannot forward after response has been committed.
Sir, help me.What can do?
 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Try this,

And As you are working in Action class , you can use mapping.findForward("session"); to forward to index.do page !

Googled this exception , you ll find lots of useful links !
 
Amit Indore
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sir,
If i use mapping.findForward("session"); then i need to put mapping in
struts- config .xml for every Action.

<forward name="session" path="/Index.do"/>

this is very heavy process. So please give another way.

Thanks

Amit Jain
 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Amit Indore:
Sir,
If i use mapping.findForward("session"); then i need to put mapping in
struts- config .xml for every Action.


No , you dont have, There is a tag in struts-config file as <global-forwards>

you can define this forward tag init , like



Try this,
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic