aspose file tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes TagSupport vs TagBodySupport Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Professional Certification » Web Component Certification (SCWCD/OCPJWCD)
Reply Bookmark "TagSupport vs TagBodySupport" Watch "TagSupport vs TagBodySupport" New topic
Author

TagSupport vs TagBodySupport

tony lee
Ranch Hand

Joined: Jan 21, 2002
Posts: 52
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,


SCJP2, SCWCD
Carl Trusiak
Sheriff

Joined: Jun 13, 2000
Posts: 3340
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.


I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
 
 
subject: TagSupport vs TagBodySupport
 
Threads others viewed
Custom Tag Handler
doAfterBody
printing from doAfterBody in tag handler
IterationTag-TagSupport
Help with the following ques
MyEclipse, The Clear Choice