• Post Reply Bookmark Topic Watch Topic
  • New Topic

<c:catch> will work only for runtime exceptions?

 
Parthiban Malayandi
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I studied about <c:catch> tag and tried a program.
Here's the snippet


<c:catch>
<%@ include file = "test.jsp" %>
</c:catch>
This test will appear if catch works

I expected that catch will work but it didn't.

then I tried with <jsp:include > and <c:import > and it worked
as I expected .

later I understood that include directive will be translated
during compile itself where as the other two(standard action and jstl tag)
will be translated at runtime and that's why catch didn't
work for "include standard action" which has been stopped by
container even before the translation

What I understood is right ?

Thanks in advance







 
Chinmaya Chowdary
Ranch Hand
Posts: 437
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Parthiban.

I think, c:catch will works for include files also.
Inorder to test wether it works or not? Add some exception generated code in 'test.jsp' and test like
 
Parthiban Malayandi
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Chinmaya,

Thanks for your reply and I tried as you said and <c:catch> works for include directive also.

I also learned that if that jsp page(e.g test.jsp) itself
doesn't exists means it didn't works rather it throws file not found exception since it is trying to include content of the file (test.jsp)during translation time itself .
where if we use include standard action or import jstl tag .it compiles fine and it's trying to include the content only at request (run time )time which is caught by <c:catch> tag .

once again thanks for your reply .
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!