Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question on doEndTag()

 
Parth Twari
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
source :wizlab

If an exception is encountered during the evaluation of body of tag the doEndTag() method of tag will not be called?
true/false
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2415
95
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Marcus,

What do you think is the answer? It is nice to submit your ideas with the question.....

Just write a small web-app and try it, you can have a look at this previous thread.

Regards,
Frits
 
Parth Twari
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey frits,

i tried it at last

and got the result as true

the doEndTag() will not be evaluated.

When any of doStartTag and doAfterBody or body of tag itself throws exception then the processing stops right there only and the tag and page is not evaluated further.

Thanks

Parth

If someone wants the code , tell me
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2415
95
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Parth,

Correct! Now to make things a bit more complicated: let me ask you another question:

What if the tag (where the exeption is thrown) is in an included jsp ->
a) the processing of the included jsp and the including jsp stops
b) the processing of the included jsp stops and the including jsp continues

what do you think?

Regards,
Frits
 
Parth Twari
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well..

From what I have read :

if the tag in an included jsp throws SkipPageException

then the further processing of the tag and the included jsp stops

and the including jsp continues with its processing.

I thought similar will be the case with other exceptions as well. The tag and the included page will be stopped but the including page will continue with its processing.

But its not the case when i tested it -

When the included jsp's tag's body threw a exception then further processing of the tag and both the pages was stopped right there and exception was thrown.

So I feel the answer is (a)
right?
Does SkipPageException get special treatment?
 
Rajeev Rnair
Ranch Hand
Posts: 310
1
Java Linux Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried <jsp:include /> or the <@ include %> directive?
 
Parth Twari
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried <jsp:include /> or the <@ include %> directive?


I used <jsp:include />
if we use <@ include %> directive the it will be no difference the new jsp and the tag will become part of our jsp and that we have tested allready

showing us that when our jsp's tag throws an exception then processing will be terminated there itself.
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2415
95
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So I feel the answer is (a)
right?
Does SkipPageException get special treatment?

Yes, the SkipPageException is an exception on the JspException's: it was meant for SimpleTags (thrown from doTag()) to have a simular behaviour possible like the Classis Custom Tag doEndTag() return code SKIP_PAGE.

Regards,
Frits
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic