• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to catch errors inJSP  RSS feed

 
amit bhadre
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am catching error page by isError page but could not do properly can u guide me any one...


thanks advance

cheers
amit bhadre
 
Frederic Esnault
Ranch Hand
Posts: 284
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Three ways to catch errors:

To redirect to an error page:
1. declare one jsp as being the error page:
<%@ page isErrorPage="true" %>
2. declare the error-risky page as having an error page :
<%@ page errorPage="error.jsp" %>
Where error.jsp is the name of the first jsp (in 1.)

Yet another way to redirect, but works for the whole web app:
Declare in DD the exception-type to catch or the error code to catch and associate to a page:
<error-page>
<exception-type> fully qualified excpetion class </exception-type>
<location>/error.jsp</location>
</error-page>

And finally, the c:catch JSTL tag :

<c:catch var="errVar">
risky code
<c:catch>

var is optional. If defined, it may be used AFTER the catch block to get error message like this :
${errVar.message}
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!