and i used redirection when user is not authentic
HttpServletResponse hres = (HttpServletResponse) response;
hres.sendRedirect("/login.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
--
Michael Ageeb Fakhry
Software Developer OpenCraft
Home Phone: +2 03 5053707
Business Phone: +2 02 3363848 / 110
Mobile Phone: +2 010 1336546
Business E-mail : [EMAIL PROTECTED]

