tags:

views:

49

answers:

1

I have a filter and I get Page not Found error when any client requests a JSF page in my web application. I don't know how to fix this issue.

Here is my filter code:

HttpServletRequest req = (HttpServletRequest) request;
HttpServletResponse res = (HttpServletResponse) response;
HttpSession ses = req.getSession(true);
String pageRequested = req.getRequestURL().toString();
if (ses.getAttribute("userDetails") != null) {
    fc.doFilter(request,response);      
} else {
    RequestDispatcher dis = request.getRequestDispatcher(LOGIN_PAGE);
    dis.forward(request,response);
}

I have done all the necessary settings in web.xml deployment descriptor.

A: 

A 404 simply means that the requested resource is not found. Down to the point this can have 2 causes:

  1. The URL is invalid (i.e. LOGIN_PAGE is invalid).
  2. The resource is not there where you think it is.

To further nail down the cause in this particular problem we need to know 2 things:

  1. What is the absolute URL of the current request? Print request.getRequestURL().
  2. What is the absolute URL with which you can open the login page independently in webbrowser?

Then, you should be able to extract the correct LOGIN_PAGE from this information.

BalusC
public static LOGIN_PAGE="faces/login.jsp"Here this LOGIN_PAGE vaue This is correct only But why this 404 error occured
johnbritto
Because the relative URL is not correct. Once again, please mention absolute URL of the current request and the absolute URL of the login page itself.
BalusC