Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

doInitBody()

 
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi!
here is a tag-handler class. In JSP API, it has been given that if the doStartTag() method returns EVAL_BODY_INCLUDE, then doInitBody() method will not be invoked. It will only be invoked if doStartTag() returns EVAL_BODY_BUFFERED. But in the given class, the doInitBody() method is invoked even the doStartTag() returns EVAL_BODY_INCLUDE. Please clear where i am wrong.
ashok.
_____________
package mytagdir;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import java.io.*;
public class MyPage extends BodyTagSupport {
public int doStartTag() throws JspException {
return EVAL_BODY_INCLUDE;
}
public void doInitBody() throws JspException {
System.out.println("initBody()");
}
public int doAfterBody() throws JspException {
return SKIP_BODY;
}
public int doEndTag() throws JspException {
return EVAL_PAGE;
}
}
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
doInitBody() and doAfterBody() will be invoked when you return EVAL_BODY_INCLUDE. But the setBodyContent() method will be invoked only when you return EVAL_BODY_BUFFERED from doStartTag()
(This is what i saw when i try testing). But the API Says when you return EVAL_BODY_INCLUDE , doInitBody() will not be invoked.
Thanks!
Satish Kolli,SCJP2
[This message has been edited by satish kolli (edited October 31, 2001).]
 
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by satish kolli:
doInitBody() and doAfterBody() will be invoked when you return EVAL_BODY_INCLUDE. But the setBodyContent() method will be invoked only when you return EVAL_BODY_BUFFERED from doStartTag()
(This is what i saw when i try testing). But the API Says when you return EVAL_BODY_INCLUDE , doInitBody() will not be invoked.
Thanks!
Satish Kolli,SCJP2
[This message has been edited by satish kolli (edited October 31, 2001).]


So the spec is wrong? Can any one clear this?
 
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it says clearly on the spec (API) that doInitBody will be called only if doStartTag return EVAL_BODY_BUFFERED... so IMHO, something is wrong in the "implementation" u are using.
 
It looks like it's time for me to write you a reality check! Or maybe a tiny ad!
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic