Tuesday, June 26, 2012

org.springframework.web.HttpSessionRequiredException: Session attribute 'user' required - not found in session

This error comes when the default session of spring expires, and we try to fetch user from @SessionAttribute("user").

The solution is to override the session timing in web.xml:

<session-config>
     <session-timeout>60</session-timeout>
 </session-config>

This will increase your session time to 60 minutes, now you will get this error after 60 mins of idle time.

We can also redirect it to the login page by the following entry in web.xml:

<error-page>
  <exception-type>
       org.springframework.web.HttpSessionRequiredException
  </exception-type>
  <location>/redirect.jsp</location>
</error-page>


No comments:

Post a Comment