posted 16 years ago
Hi All,
I have a filter in which I redirect the screen to login page, if the url is directly pasted in the browser. It works fine but when the application is in use and suddenly user pastes the URL in the browser of index page, I need to clear some faces session values and redirect the screen to login and in the else part of my code I am not able to get the handle of facesContext (To clear the Backing bean values).
Pls advice me. Any better approach to redirect to the index screen is welcome.
public void doFilter(ServletRequest req, ServletResponse res,
FilterChain filterChain) throws IOException, ServletException {
if ((req instanceof HttpServletRequest)
&& (res instanceof HttpServletResponse)) {
HttpServletRequest request = (HttpServletRequest) req;
if (request.getMethod().equals("GET")) {
if (!request.getRequestURL().toString().equals(
"LoginScreen")) {
request.getSession().invalidate();
((HttpServletResponse) res)
.sendRedirect("LoginScreen");
return;
}
} else {
//FacesContext.getCurrentInstance() returns me null
}
}
filterChain.doFilter(req, res);
}