• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is returning invalid integer from doStartTag() is equivalent to returning EVAL_BODY_INCLUDE ?

 
Bindu Lakhanpal
Ranch Hand
Posts: 171
Flex Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If i return invalid integer value from doStartTag() in following code,no exception occurs,which is understandable since return type of doStartTag() is integer.But what i got as output is as if EVAL_BODY_INCLUDE (which is equal to 1)is returned.


The out put is as follows:

in doStartTag with 23(invalid) return value This is tag body which can be jsp -----in doAfterBody-----in doEndTag
Is it container specific behaviour ( I am using Tomcat )or is it what jsp spec says?
Even if i return other values like SKIP_PAGE (which is valid for doEndTag()), i got same output as above.
 
Christophe Verré
Sheriff
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think that it's explicitly written in the spec. I think it's container dependent, so you'd better be sure to return the correct value.
 
Bindu Lakhanpal
Ranch Hand
Posts: 171
Flex Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok.Thanks.

If i returned invalid integer from doAfterBody(),it behaved as if SKIP_BODY is returned.
Returning invalid integer from doEndTag() gave output as if EVAL_PAGE is returned.
These are default return values unlike EVAL_BODY_INCLUDE in case of doStartTag().

If such a question comes in exam(although probability is low),should the answer be "container dependent"
 
Christophe Verré
Sheriff
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you have to know which constant can be returned. There is no container dependent question at the exam.
 
Chinmaya Chowdary
Ranch Hand
Posts: 432
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bindu.
Make sure that we should not return the value '0'(which is default return value of SKIP_BODY) in doStartTag(). If we return, the body will not be evaluated. Tomcat will checks that condition.
Tomcat is not performing may conditional checks incase of ClassicTags. If they performs, if affect on performance.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic