File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes JSTL catch block Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "JSTL catch block" Watch "JSTL catch block" New topic
Author

JSTL catch block

satyam bobba
Greenhorn

Joined: Jan 30, 2006
Posts: 10
first.jsp
-------------------------
<%@ page errorPage="testerror.jsp" %>
First Line


<c:catch var="myException">

<% int x=10/0 %>


</c:catch>

<c:if test="${myException!=null}">

There was an exception : ${myException.message}

</c:if>


testerror.jsp
------------------

Hai,you are in error page.




What is the out put of this page?

It includes the output of first.jsp and testerror.jsp/testerror.jsp?
satyam bobba
Greenhorn

Joined: Jan 30, 2006
Posts: 10
first.jsp
-------------------------
<%@ page errorPage="testerror.jsp" %>
First Line


<c:catch var="myException">

<% int x=10/0 %>


</c:catch>

<c:if test="${myException!=null}">

There was an exception : ${myException.message}

</c:if>


testerror.jsp
------------------
<%@ page iserrorPage="true" %>

Hai,you are in error page.




What is the out put of this page?

It includes the output of first.jsp and testerror.jsp/testerror.jsp?
Marcelo Ortega
Ranch Hand

Joined: May 31, 2005
Posts: 519

To start off with, the page will not compile because the scriplet which is suppose to trigger the excpetion is missing the ';'.
But if we were to correct this problem, then the runtime exception will be thrown and caught from the <catch> tag.
Bottom line: if your page declares an errorPage but wraps the exception to be thrown in a <catch> tag, it is classified as handled and will not be forwarded to the errorPage; else if no <catch> is present, the request is forwarded to the errorPage.

regards,
Mars.


SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJD, SCEA/OCMJEA

Live life to an interface, not an implementation!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSTL catch block