• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

doStartTag valid return checked @ compile time??

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Assuming the rest of the code is valid,
which is true about this code?
public class TestTag extends TagSupport{
public int doStartTag(){
try{
JspWriter out=pageContext.getOut();
out.println("Customize");
}//try
catch(IOException ioex){}
return(EVAL_BODY_BUFFERED);
I answered B, because I thought since EVAL_BODY_BUFFERED is not a valid return type, it would throw some run time exception.
Correct answer:
Will not compile. EVAL_BODY_BUFFERED is not a valid return type for a tag that extends TagSupport. EVAL_BODY_INCLUDE or SKIP_BODY would be ok.
How can it check @ compile time???
 
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by amol re:
Assuming the rest of the code is valid,
which is true about this code?
public class TestTag extends TagSupport{
public int doStartTag(){
try{
JspWriter out=pageContext.getOut();
out.println("Customize");
}//try
catch(IOException ioex){}
return(EVAL_BODY_BUFFERED);
I answered B, because I thought since EVAL_BODY_BUFFERED is not a valid return type, it would throw some run time exception.
Correct answer:
Will not compile. EVAL_BODY_BUFFERED is not a valid return type for a tag that extends TagSupport. EVAL_BODY_INCLUDE or SKIP_BODY would be ok.
How can it check @ compile time???


Dear Amol,
In your TestTag.java, u have extended TagSupport class..
TagSupport implements IterationTag interface and provides implementations for each of the methods of the Tag and IterationTag interfaces.
EVAL_BODY_BUFFERED is the constant defined in interface BodyTag so ur file will not compile..
for ur java file to compile u have to extend BodyTagSupport class which implements the BodyTag class..
Thanks
Raj
 
Rajeev Ravindran
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A small correction

for ur java file to compile u have to extend BodyTagSupport class which implements the BodyTag class


for ur java file to compile u have to extend BodyTagSupport class which implements the BodyTag interface
Thanks
raj
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic