Error page Web XML tag in JSP

Use of web.xml Error page tag ?

Explanation

Error page XML tag is used for custom "error handling" of web applications.Using this tag multiple error pages can be defined.

Example :


<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<error-page>
<error-code>404</error-code>
<location>/jsp/error/PageNotFound.jsp</location>
</error-page>
</web-app>

In the above error page web.xml example the "error-code" tag is used to specify the error code like "404", "500" and the "location" tag specifies the location of the jsp page.

Ask Questions

Ask Question