wood burning stoves 2.0*
The moose likes JSP and the fly likes Custom JSP tags Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Custom JSP tags" Watch "Custom JSP tags" New topic
Author

Custom JSP tags

Mike Tabak
Ranch Hand

Joined: Mar 31, 2012
Posts: 40
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
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1016
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Custom JSP tags
 
Similar Threads
Taglib directive: Mandatory attribute uri missing
doAfterBody() is not executed using BodyTagSupport
BodyContent
BodyTag doubt
tag handler interacting with body of tag....