Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Classic tag and JspException

 
Suhas Wadadekar
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
For a classic tag handler, TagSupport class needs to be extended. In this, the doStartTag and doEndTag methods throw JspException but not IOException. In the examples in HFSJ, the print method of such tag handlers are understandably enclosed by try/catch blocks to catch IOException.

However, why does the catch block throw a JspException after successfully intercepting an IOException?

Thanks,
Suhas.
 
raj malhotra
Ranch Hand
Posts: 288
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why does the catch block throw a JspException after successfully intercepting an IOException?


It cannot throw IOException.
This is the one of the method signature from TagSupport:



Since the above method does not declare that it can throw IOException, so it cannot.

I think better question would be why classic tag only throws JspException but simple tag throws both IOException and JspException?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65335
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suhas Wadadekar wrote:However, why does the catch block throw a JspException after successfully intercepting an IOException

What should it do? Just eat the exception and pretend nothing ever happened? Really?

JspException is a container exception; the IOException should be set as its root cause and the JspException thrown so that the exception can continue to propagate and be reported.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic