Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

TagSupport vs TagBodySupport

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:
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?
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.
A magnificient life is loaded with tough challenges. En garde tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic