asked in JSP by (58.6k points)

1 Answer

To handle exceptions thrown by the JSP page, all we need is an error page and define the error page in JSP using page directive.

To create a JSP error page, we need to set page directive attribute isErrorPage value to true, then we can access exception implicit object in the JSP and use it to send customized error message to the client.

We need to define exception and error handler JSP pages in the deployment descriptor like below.

	<error-page>
   		<error-code>404</error-code>
   		<location>/error.jsp</location>
   </error-page>
    
   <error-page>
   		<exception-type>java.lang.Throwable</exception-type>
   		<location>/error.jsp</location>
   </error-page>
answered by (58.6k points)

Java Interview Questions and Answers 2018

>
...