First off, I see that my changes to the extensions filter setup web
page have gotten lost.   I'll try to get them back in tomorrow.  
Here's the recommended extensions filter mapping.  This assumes you've
named your FacesServlet "FacesServlet" as well.

    <!-- extension mapping for adding <script/>, <link/>, and other
resource tags to JSF-pages  -->
    <filter-mapping>
             <filter-name>MyFacesExtensionsFilter</filter-name>
             <!-- servlet-name must match the name of your
javax.faces.webapp.FacesServlet entry -->
             <servlet-name>FacesServlet</servlet-name>
    </filter-mapping>
        
    <!-- extension mapping for serving page-independent resources
(javascript, stylesheets, images, etc.)  -->
    <filter-mapping>
             <filter-name>MyFacesExtensionsFilter</filter-name>
             <url-pattern>/faces/myFacesExtensionResource/*</url-pattern>
    </filter-mapping>

    <!-- FacesServlet -->
    <servlet>
        <servlet-name>FacesServlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

This is how I would do it.  I'm not really an expert on filters or
servlets however.   I've written a few and they work for me, so use
your own judgement.

List your filter mapping before the MyFacesExtensionsFilter.  You will
probably want this to be the very first filter mapping executed.

It'd probably look something like this:

    <!-- your session-checking filter  -->
    <filter-mapping>
             <filter-name>YourSessionCheckingFilter</filter-name>
             <servlet-name>FacesServlet</servlet-name>
    </filter-mapping>

If you only care about expired sessions for /faces/admin pages, then
I'd explicitly check for that path in your filter rather than mapping
it as /faces/admin.

I don't remember the exact value to check, but it should be trivial to
find using the debugger or some logging statements.  It's probably
request.getPathTranslated() as I browse the javadocs.

The code will look something like this.   This probably doesn't
redirect, however.

    public void doFilter(ServletRequest servletRequest,
ServletResponse servletResponse, FilterChain chain) throws
IOException, ServletException
    {
        HttpServletRequest request = ((HttpServletRequest)servletRequest);
        HttpServletResponse response = ((HttpServletResponse)servletResponse);

        boolean redirect = sessionIsExpiredAndPathIsFacesAdminPath(request);

        if (redirect)
        {
            executeTheRedirect(request, response);
            return;
        }

        chain.doFilter(servletRequest, servletResponse);
    }



On 2/27/06, Elam Daly <[EMAIL PROTECTED]> wrote:
> Mike,
>
> Using the filter method seems to present a problem.
>
> In my web.xml file, I already have a filter for any /faces/* requests that
> invokes the ExtentionsFilter for myfaces.  The url I need for *my* filter is
> /faces/admin/*.  So it seems to me that in order to use my filter, that I
> need to use the doChain() method in the myfaces filter class, which I can do
> I suppose, but that would mean grabbing the sources and such, which I'd
> rather not do.
>
> I've never written a filter before, so I could be wrong about this.  But my
> filter doesn't respond to any requests for /faces/admin, but it does, for
> say /*, so I'm assuming that the myfaces filter is not passing on the
> request to the next filter in the chain.
>
> Is that right?
>
> Thanks,
> -Elam
>
>
> On 2/27/06, CONNER, BRENDAN (SBCSI) <[EMAIL PROTECTED]> wrote:
> > Or register a listener that implements HttpSessionListener, which
> > implements the methods sessionCreated(HttpSessionEvent e) and
> > sessionDestroyed(HttpSessionEvent e).
> >
> > -----Original Message-----
> > From: Mike Kienenberger [mailto:[EMAIL PROTECTED]
> > Sent: Monday, February 27, 2006 3:34 PM
> > To: MyFaces Discussion
> > Subject: Re: Session Expiration Default Target?
> >
> >
> > A servlet filter is probably the best bet since you can both check for
> > the expired session and redirect before JSF is ever involved.
> >
> > On 2/27/06, Elam Daly < [EMAIL PROTECTED]> wrote:
> > > Hi all,
> > >
> > > Is there someway to tell my faces application that when the session
> > has
> > > expired, to return to a certain page?
> > >
> > > I have a session time of 5 minutes for my application and the pages
> > are
> > > password protected.  What's happening is that people are clicking on
> > the
> > > links and what not after the session expiration date, and the app is
> > > throwing errors.  The password protection is custom, not tomcat
> > container
> > > authentication, so I need to do the redirecting via JSF.
> > >
> > > Thanks,
> > > Elam Daly
> > >
> >
>
>

Reply via email to