Your web.xml looks ok to me, although my url-pattern begins with "/".

I've something like this in my working Filter:

        public void doFilter(ServletRequest pRequest, ServletResponse
pResponse, FilterChain pChain) throws IOException, ServletException {           
                HttpServletRequest lRequest = (HttpServletRequest) pRequest;
                                
                if (! lRequest.isRequestedSessionIdValid() &&
lRequest.getRequestedSessionId() != null) {

                        log.debug("invalidated session detected!");             
                        
                        FacesContext lContext = getFacesContext(pRequest, 
pResponse);                   
                                
                        lRequest.getSession().invalidate();
                                
                        lRequest.getSession(true);
                                
                                
lContext.getApplication().getNavigationHandler().handleNavigation(lContext,
null, "session_expired");                               
                } else {                        
                        pChain.doFilter(pRequest, pResponse);                   
                }
        }

The "session_expired" is the normal jsf outcome.

I hope that helps.

Veit


Thomas Chang schrieb:
> Hi,
> 
> I do following:
> 1.
> set filter in web.xml as follow:
> <filter>
>   <filter-name>sessionExpiredFilter</filter-name>
>   <filter-class>
>   my.utils.SessionExpiredFilter
>   </filter-class>
> </filter>
> ...
> <filter-mapping>
>   <filter-name>sessionExpiredFilter</filter-name>
>   <url-pattern>*.jsf</url-pattern>
> </filter-mapping>
> 
> 2.
> And here is my filter class:
> public class SessionExpiredFilter {
> private String page = "/jsp/login/login.xhtml";
> 
> public void destroy() {
> }
> 
> public void doFilter(ServletRequest request, ServletResponse response,
>         FilterChain chain) throws IOException, ServletException {
> if (((HttpServletRequest) request).getRequestedSessionId() != null
>         && ((HttpServletRequest) request).isRequestedSessionIdValid() ==
> false) {
>  RequestDispatcher rd = request.getRequestDispatcher(page);
>  rd.forward(request, response);
> } else {
>  chain.doFilter(request, response);
>     }
> }
> 
> public void init(FilterConfig filterConfig) throws ServletException {
> if (filterConfig.getInitParameter("page") != null) {
>     page = filterConfig.getInitParameter("page");
>   }
>  }
> 
> }
> 
> But it doesn't work. If the timeout comes, it dosen't redirect.
> 
> Could you please show me your filter class?
> 
> Regards
> 
> Thomas
> 
> 
> 
> */Veit Guna <[EMAIL PROTECTED]>/* schrieb:
> 
>     Hi.
> 
>     Yes, I use a filter to handle session-timedout requests. The next
>     time an invalidated session is requested, a redirect will be done.
> 
>     Regards,
>     Veit
> 
>     -------- Original-Nachricht --------
>     Datum: Tue, 13 Mar 2007 15:11:45 +0100 (CET)
>     Von: Thomas Chang
>     An: [email protected]
>     CC:
>     Betreff: Question about redirection on timeout
> 
>     > Hi all,
>     >
>     > I set the timeout in the web.xml and it works find. What I want
>     now is: if
>     > the timeout comes, it redirects to the login.xhtml. How can I do that?
>     > Seems I have to rewrite the filter?
>     >
>     > Regards
>     >
>     > Thomas
>     >
>     >
>     > ---------------------------------
>     > Was Sie schon immer wissen wollten aber nie zu Fragen trauten? Yahoo!
>     > Clever hilft Ihnen.
> 
>     -- 
>     "Feel free" - 5 GB Mailbox, 50 FreeSMS/Monat ...
>     Jetzt GMX ProMail testen: www.gmx.net/de/go/mailfooter/promail-out
> 
> 
> ------------------------------------------------------------------------
> Der neue Internet Explorer 7 in deutscher Ausführung ist da
> <http://de.rd.yahoo.com/evt=44263/*http://de.downloads.yahoo.com/internetexplorer/index.php>!
> 

Reply via email to