• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Custom JSP tags

 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a question about implementing a class for a custom tag that extends BodyTagSupport. If the doStartTag() method returns EVAL_BODY_BUFFERED I know a BodyContent object is automatically created and the doInitBody() and doAfterBody() methods are called. The doAfterBody() method I'm looking at will get a JspWriter and write out the BodyContent. My question is I don't see where data is added to the BodyContent object. There is some code in the doInitBody() and doAfterBody() that can call pageContext.setAttribute() with data to be displayed by the JSP page. Does these calls to pageContext.setAttribute() cause the data to be saved in the BodyContent object?

Thanks
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Reference: http://docs.oracle.com/javaee/6/api/javax/servlet/jsp/tagext/BodyTag.html

The setting of the body is done by the servlet container you are running in.
It is doing stuff in the background and just every now and again consulting you to find out what you want to do with it.

According to the lifeCycle it will setBodyContent() before calling doInitBody()
It will then call evaluate the body, and call doAFterBody()

The logic around setting the body and evaluating it is internal to the servlet container
 
reply
    Bookmark Topic Watch Topic
  • New Topic