This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

TagSupport vs TagBodySupport  RSS feed

 
tony lee
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends,
I tried two handler classes: One implementing TagBodySupport and another TagSupport.
code 1

code 2

The JSP file including code:
<utile:my>
<i>Hello</i>
</utile:my>
With code 1, browser print Hello
With code 2, there's an exception like
javax.servlet.ServletException: (class: org/apache/jsp/$2_0005f5$jsp, method: _jspService signature: (Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse V) Incompatible object argument for function call ...
Could someone tell me why?
Thanks,
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
TagSupport is for Tags which do NOT manipulate the Body of the tag at all. Therefore none of the methods that are necessary for Body Manipulation are present in this Heirarchy. Tags work mainly by reflection since you return EVAL_BODY_INCLUDE the Container is trying to use reflection to find the methods for doInitBody and they aren't there!
If you aren't doing any thing with the body, your doStartTag method should return SKIP_BODY which will prevent the error caused by reflection.
If you do need to manipulate the body, subclass BodyTagSupport instead.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!