ComeRun
ComeRun

Reputation: 921

Websphere and Tomcat custom error file right directory

I have set the following into my web.xml for both Websphere and Tomcat:

  <error-page>
      <error-code>404</error-code>
      <location>/error404.html</location>
  </error-page>

But somehow I am not sure where to put the error-404.html page! Its not being picked up by Websphere or Tomcat (I am testing on both servers on different servers).

Can anyone please instruct me on this? Is this configuration enough or are other configurations are also needed to set a custom error page for 404, 403, etc.?

Upvotes: 1

Views: 179

Answers (1)

Jake Stoeffler
Jake Stoeffler

Reputation: 2905

Servlet 3.0 spec says:

The error-page contains a mapping between an error code or an exception type to the path of a resource in the Web application. The sub-element exceptiontype contains a fully qualified class name of a Java exception type. The sub-element location element contains the location of the resource in the web application relative to the root of the web application. The value of the location must have a leading ‘/’.

So for the location /error404.html you should put error404.html in the application root (next to, but not inside, the WEB-INF directory).

Upvotes: 1

Related Questions