We have to use the error-page element in web.xml to specify the invocation of servlets in response to certain exceptions or HTTP status codes.
How to configure a central error handler in servlets?
If we want to have a generic Error Handler for all the exceptions then we should define following error-page instead of defining separate error-page elements for every exception:
<error-page> <exception-type>java.lang.Throwable</exception-type > <location>/ErrorHandler</location> </error-page>
- What is a Web application?
- What is a Web browser?
- What is different between web server and application server?
- What is a servlet container?
- What is MIME Type?
- Why do we need a constructor in a servlet if we use the init method?
- When servlet object is created?
- Who is responsible for creating the servlet object?
- What is the difference between HttpServlet and GenericServlet?
- What is HTTPServletRequest class?
- What is HTTPServletResponse class?
- How can we create deadlock condition on our servlet?
- For initializing a servlet can we use a constructor in place of init()?
- How to read form data in servlet?
- How to write html contents using servlets?
- How to send an authentication error from a servlet?
- What is servlet collaboration?
- What is lazy loading?
- How do we call one servlet from another servlet?
- What is the difference between sendRedirect and RequestDispatcher?
- Can we call a jsp from the servlet?
- How to configure a central error handling page in servlets?
- How to get session object?
- How to set attribute in session object?
- How to get attribute from session object?