top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How can we handle exceptions thrown by JSP service method?

+1 vote
411 views
How can we handle exceptions thrown by JSP service method?
posted Aug 24, 2017 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

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>
answer Aug 31, 2017 by Mantosh Dubey
...