Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

TagSupport vs TagBodySupport

 
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic