Domanda

I'm creating a web application using guice 3.0 on a tomcat 7 server.

I managed to use a static file to customize my error 404 page but now I need to customize the error 404 page using a servlet.

So, in my web.xml I add those lines:

<error-page>
    <error-code>404</error-code>
    <location>/error</location>
</error-page>

and in my module configuration

 serve("/error").with(ErrorServlet.class);

If I access directly the /error page from the browser it works. But if I ask voluntarily for a non existing page, I have a blank page. The browser has received the 404 status but there is no content. Furthermore, I have added log traces to the servlet and it appears that it is not even called.

Thanks in advance for your help.

È stato utile?

Soluzione

Ok I forgot that guice works as a filter so do not forget to add this line to your web.xml

<dispatcher>ERROR</dispatcher>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top