This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Is returning invalid integer  from doStartTag() is equivalent to returning  EVAL_BODY_INCLUDE ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Is returning invalid integer  from doStartTag() is equivalent to returning  EVAL_BODY_INCLUDE ?" Watch "Is returning invalid integer  from doStartTag() is equivalent to returning  EVAL_BODY_INCLUDE ?" New topic
Author

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

Bindu Lakhanpal
Ranch Hand

Joined: Oct 17, 2008
Posts: 171

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

Joined: Nov 24, 2005
Posts: 14688
    
  16

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.


[My Blog]
All roads lead to JavaRanch
Bindu Lakhanpal
Ranch Hand

Joined: Oct 17, 2008
Posts: 171

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

Joined: Nov 24, 2005
Posts: 14688
    
  16

I think you have to know which constant can be returned. There is no container dependent question at the exam.
Chinmaya Chowdary
Ranch Hand

Joined: Apr 21, 2008
Posts: 432
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.
 
subject: Is returning invalid integer from doStartTag() is equivalent to returning EVAL_BODY_INCLUDE ?