Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSTL catch block

 
satyam bobba
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 528
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic