Eric Lemle wrote the following on 2/16/2005 4:22 PM:
If the session expires and then they click on something it runs the
action and then the action tries to get some info from the session
which causes a null pointer exception. Is there anyway to have a
pre-filter rather than a post-filter to send them to the page that
says,
says ex.-> 'your session has expired, please login again'
Sure just set up a servlet filter that looks for a valid session and if
there isn't one you forward them to that page. Define your filter in
your web.xml. I think the tomcat docs show an example... but for my app
I have something like...
NdaFilter
com.nielsenmedia.nda.ui.filter.NdaFilter
NdaFilter
*.do
NdaFilter
*.jsp
In your custom Filter class which extends javax.servlet.Filter, you'll
have a doFilter method in it where you'd add something like...
HttpServletRequest request = (HttpServletRequest)req;
HttpServletResponse response = (HttpServletResponse)res;
String contextPath = request.getContextPath();
HttpSession session = request.getSession(false);
if (session == null) {
log.debug("The session no longer exists");
response.sendRedirect(contextPath+"/sessionTimeOut.jsp");
return;
} else {
filterChain.doFilter(req, res);
}
(Could be much better ways to accomplish the above, but the above should
work)
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]