Why <error-page> in web.xml does not work ?
843842Sep 4 2008 — edited Sep 4 2008I need to dispaly my error page when java.lang.NumberFormatException in thrown. How to do that with web.xml error-page tag?
This is my web.xml
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<display-name>Welcome to Tomcat</display-name>
<description>Welcome to Tomcat</description>
<!-- JSPC servlet mappings start -->
<servlet>
<servlet-name>first</servlet-name>
<servlet-class>servlet.PostNumber</servlet-class>
</servlet>
<servlet>
<servlet-name>second</servlet-name>
<servlet-class>servlet.NumbException</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>first</servlet-name>
<url-pattern>/firstpage</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>second</servlet-name>
<url-pattern>/secondpage</url-pattern>
</servlet-mapping>
<error-page>
<exception-type>java.lang.NumberFormatException</exception-type>
<location>/error.html</location>
</error-page>
<!-- JSPC servlet mappings end -->
</web-app>
I put my error.html in ( /web-app/myweb/jspfile/error.html ) this location.
When i use URL: http://localhost:8080/myweb/firstpage the servlet display here. when )(java.lang.NumberFormatException) this exception occur it display
In browser msg like this::
The webpage cannot be found
HTTP 404
Most likely causes:
There might be a typing error in the address.
If you clicked on a link, it may be out of date.
My configuration in web.xml is correct? and why i am getting this error?
Thanks in advance,
S.Shyam.