chaitanya89
chaitanya89

Reputation: 847

Java - Why custom 404 error page is being executed even though a valid resourse is called?

In our java dynamic web project, we have 404 custom page registered in web.xml like this,

<error-page>
    <error-code>404</error-code>
    <location>/404Error.jsp</location>
</error-page>

AFAIK, 404 error page gets executed when user requests for an unavailable resource, e.g., If user accidentally types "abc.jsp"(which is not available in our project) instead of typing "Abc.jsp" and then custom error message is shown.

I've observed that our 404Error.jsp is getting executed when any valid resource is called. the code I have in 404Error.jsp is,

<% System.out.println("In 404 Error page !!")%>

I mean, we have "homePage.jsp" in our project, when I(user) call "homePage.jsp" the output of home page is displayed to me but I can see "In 404 Error page !!" sysout in my eclipse console.

Why 404Error.jsp java code is being executed even a valid resource is called?

Upvotes: 0

Views: 200

Answers (1)

piet.t
piet.t

Reputation: 11911

It might be worth activating some kind of access-log or also print request.getRequestURL() to see what request is causing the 404 - my guess is that it's the browser requesting a favicon.ico that isn't there.

Upvotes: 3

Related Questions