Title: Message
The O'Reilly book ("JavaServer Faces") has an example of how to do automatic login page redirection in its Expense Report example application.
 
- Brendan
-----Original Message-----
From: Yee CN [mailto:[EMAIL PROTECTED]
Sent: Monday, November 07, 2005 4:41 AM
To: 'MyFaces Discussion'; [EMAIL PROTECTED]
Subject: RE: Cannot do getRequestDispatcher("/login.jsf").forward() with JSF?

I solved the problem using sendRedirect(). However forward() was apparently used successfully in http://www.javaworld.com/javaworld/jw-07-2004/jw-0719-jsf.html so I am wondering whether this problem is specific to myfaces.

 

Regards,

Yee

 


From: Yee CN [mailto:[EMAIL PROTECTED]]
Sent: Monday, 7 November 2005 11:53 AM
To: 'MyFaces Discussion'
Subject: Cannot do getRequestDispatcher("/login.jsf").forward() with JSF?

 

Hi,

 

I am trying to write a very simple security filter to redirect the user to the login page if he/she is not login, something like the following:

 

            public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)

                                    throws IOException, ServletException {

 

                        if (!authenticated((HttpServletRequest)req)) {

                                    ((HttpServletRequest)req).getRequestDispatcher(“/login.jsf”).forward(req, res);

                        } else {

                                    chain.doFilter(req, res);

                        }

            }

 

But I seems to be having problems with getRequestDispatcher(“/login.jsf”).forward().

The login.jsf got forwarded to OK, however the JSF engine seems to get very confused afterwards. The URL shown in the browser window is of the following form:

 

http://localhost:8080/myapp/login.jsf;jsessionid=46D86B99BE29C1F112F1C8BD3CBA6D6D

 

and nothing works till I logon via the login page directly.

 

Anyway around this?

 

Many thanks in advance.

 

Yee

Reply via email to