aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes behaviour of doStartTag of TagSupport Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "behaviour of doStartTag of TagSupport" Watch "behaviour of doStartTag of TagSupport" New topic
Author

behaviour of doStartTag of TagSupport

Royston Monteiro
Ranch Hand

Joined: Apr 25, 2008
Posts: 35

Hi,
My CustomTagHandler that extends TagSupport:


The Jsp that calls this:


I am given to understand that by default(when the doStartTag isnt overridden, the behaviour is to skip the Body. Since I am returning neither of teh expected return values, shouldnt the default behaviour kick in? I assume returning an arbitrary return value integer is similar to not overriding the doStart method as far as default behaviou is concerned. On the contrary, I observe the below output:
The output from the Jsp is

which means that the body is evaluated.

Could someone please suggest.


Cheers,
Roy.
Sun Certified Java Programmer 1.5,
Sun Certified Web Component Developer 5.
"No pain. No Gain"
http://cs.nyu.edu/~rpm319
Venkata Kumar
Ranch Hand

Joined: Apr 16, 2008
Posts: 110

The valid return values for doStartTag() function are SKIP_BODY and EVAL_BODY_INCLUDE. If the function doStartTag is not overriden then default value SKIP_BODY is returned.

The function doStartTag is overriden and the returned value 9911 is not valid return value. The default behaviour applied only when the function is not overridden.
From the Tomcat 6.x source code it seems that if the return type is not equal to SKIP_BODY then return type is considered as EVAL_BODY_INCLUDE

if the doStarTag returns EVAL_BODY_INCLUDE and if the custom tag has body then body is evalauted once.


Hence "hello" is displayed as output


SCJP 5.0, SCWCD 5, preparing for SCDJWS
Souvik Dasgupta
Ranch Hand

Joined: Sep 24, 2009
Posts: 80

are you using Tomcat 6.x?


Thanks and Regards, Souvik
SCJP, SCWCD, OCEJWSD
Royston Monteiro
Ranch Hand

Joined: Apr 25, 2008
Posts: 35

Venkat Divvela Yesterday 02:33:22 Subject: behaviour of doStartTag of TagSupport

--------------------------------------------------------------------------------

The valid return values for doStartTag() function are SKIP_BODY and EVAL_BODY_INCLUDE. If the function doStartTag is not overriden then default value SKIP_BODY is returned.
view plaincopy to clipboardprint?
# public int doStartTag() throws JspException{
# return 9911;
# }
# public int doStartTag() throws JspException{
# return 9911;
# }
The function doStartTag is overriden and the returned value 9911 is not valid return value. The default behaviour applied only when the function is not overridden.
From the Tomcat 6.x source code it seems that if the return type is not equal to SKIP_BODY then return type is considered as EVAL_BODY_INCLUDE

if the doStarTag returns EVAL_BODY_INCLUDE and if the custom tag has body then body is evalauted once.

view plaincopy to clipboardprint?
<mytag:ClassicTag >Hello</mytag:ClassicTag>
<mytag:ClassicTag >Hello</mytag:ClassicTag>
Hence "hello" is displayed as output


Thanks. That explains it.

Souvik Dasgupta Today 14:22:40 Subject: behaviour of doStartTag of TagSupport

--------------------------------------------------------------------------------

are you using Tomcat 6.x?


Yes, I am using Tomcat 6
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: behaviour of doStartTag of TagSupport