You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Eric Lemle <er...@ihc.com> on 2005/02/16 22:22:35 UTC

? with invalid session

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'

-Eric

Eric D. Lemle
Senior Programmer / Analyst
Intermountain Health Care
36 South State Street, Suite 1100
Salt Lake City, Utah 84111 
United States of America (USA)
(801) 442-3688 -- e-mail: Eric.Lemle@IHC.com


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Menu

Posted by Marcelo Epstein <ma...@epstein.com.br>.
Hi,
I am developing a software for a company using struts. What is the best 
way to create the menus to navigate in the system?
JSF? Simple HTML with javascript? Tag libraries?

Thanks in advance,
Marcelo Epstein

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: ? with invalid session

Posted by Rick Reumann <st...@reumann.net>.
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...

<filter>
     <filter-name>NdaFilter</filter-name>
     <filter-class>com.nielsenmedia.nda.ui.filter.NdaFilter</filter-class>
   </filter>
   <filter-mapping>
     <filter-name>NdaFilter</filter-name>
     <url-pattern>*.do</url-pattern>
   </filter-mapping>
   <filter-mapping>
     <filter-name>NdaFilter</filter-name>
     <url-pattern>*.jsp</url-pattern>
   </filter-mapping>

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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org