| 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.
SCJP 1.5, SCWCD 5.
"Perseverance is the hard work you do after you get tired of doing the hard work you already did"
|
 |
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
Greenhorn
Joined: Sep 24, 2009
Posts: 22
|
|
|
are you using Tomcat 6.x?
|
Thanks and Regards
Souvik
SCJP,SCWCD
|
 |
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
|
 |
 |
|
|
subject: behaviour of doStartTag of TagSupport
|
|
|