Hasnain,
try a redirect like this:
httpResponse.sendRedirect(
httpResponse.encodeRedirectURL(LOGIN_URL )
);
);
HTH
Frank
Felix
From: Hasnain Badami [mailto:[EMAIL PROTECTED]
Sent: Tuesday, April 18, 2006 5:50 PM
To: MyFaces Discussion
Subject: Re: Faces context is nullThanks for your reply guys.I also tried to use request.getRequestDispatcher("./login.jsf").forward(request, response) instruction to forward to the login page incase of authentication failure. But when this instruction gets executed instead of loading the login page, the first page of the website (only accessible to logged in users) is shown, which is strange. I added system println statements to my code. When login.jsf is loaded for the first time the output appears, but later when i am forwarding to it after login failure it isnt.Any idea of what might be the problem.once again thanks for your repliesHassnain
On 4/18/06, Matthias Wessendorf <[EMAIL PROTECTED]> wrote:> I am trying to implement a security filter. In the doFilter method if I am
> trying to get the faces context using FacesContext.getCurrentInstance() but
> this instruction returns null.
Right!
> Any idea of why this is happening?
FacesContext is setup inside of FacesServlet.service() ([1]) for each request.
So your filter is called before service() is call. That's why you get
a null value.
> Actually on authentication failure I would like to reload the login page and
> the main purpose of getting the facescontext is to get the navigationhandler
> and load the login page. Any alternative ideas would be highly appreciated.
J2EE based security might be usful. Or ou may try a PhaseListener
instead, which is called *inside* the Faces framework.
[1] http://tinyurl.com/ha6s5
> Thanks
>
> Hassnain
--
Matthias Wessendorf
Aechterhoek 18
48282 Emsdetten
http://jroller.com/page/mwessendorf
mwessendorf-at-gmail-dot-com