Showing posts with label Servlets. Show all posts
Showing posts with label Servlets. Show all posts

Thursday, January 26, 2012

Configuring Exception page in web.xml

Instead of showing error page for individual action performed in Servlet,JSP,It is always recommended to configure those error page in web.xml

<web-app>

             <servlet>
                       <!-- some servlet cofiguration -->
             </servlet>

             <servlet-mapping>
                       <!-- some servlet mappings-->
             </servlet-mapping>

            <welcome-file-list>
                         <!-- Welcomefile list configurations-->
            </welcome-file-list>

              <error-page>
                        <error-code>404</error-code>
                        <location>/pagenotfound.jsp</location>
               </error-page>
         
                <error-page>
                         <exception-type>java.lang.Exception</exception-type>
                         <location>/error.jsp</location>
               </error-page>
</web-app>