Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Not the expected output: EVAL_BODY_TAG

 
Raul Martinez
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here I am again. Still following the PDF book Core Servlets & JavaServer Pages, 1st Ed. I'm having some problem with the output of the following java/jsp/xml codes. I'm expecting that output would be

Simple Loop Tag
Loop max: 3
Hello!Hello!Hello!
End of Counter


but the output of the JSP when excuted is:

Simple Loop Tag
Loop max: 3
End of Counter


This is not what I've expected... thanks again!
more power to all!

jm


 
Hans Bergsten
Author
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Raul Martinez:
[QB]Here I am again. Still following the PDF book Core Servlets & JavaServer Pages, 1st Ed. I'm having some problem with the output of the following java/jsp/xml codes. ...

Maybe it's time to buy a book without errors ;-)
The doStartTag() can't return EVAL_BODY_AGAIN. That's a code reserved for the doAfterBody() method. Try returning EVAL_BODY_BUFFERED instead.
 
Raul Martinez
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sir Hans,
Sorry about the EVAL_BODY_AGAIN... actually I was thinking that I should put EVAL_BODY_INCLUDE. Anyhow, I replaced the EVAL_BODY_AGAIN to EVAL_BODY_BUFFERED
but still the output is

Simple Loop Tag
Loop max: 3
End of Counter

Replacing EVAL_BODY_AGAIN of doStartTag produces this output:

Simple Loop Tag
Loop max: 3 Hello!
End of Counter

still... not the expected output
jm
 
Hans Bergsten
Author
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Raul Martinez:
Sir Hans,
Sorry about the EVAL_BODY_AGAIN... actually I was thinking that I should put EVAL_BODY_INCLUDE. Anyhow, I replaced the EVAL_BODY_AGAIN to EVAL_BODY_BUFFERED
but still the output is

still... not the expected output
jm

EVAL_BODY_BUFFERED is the correct value for this example, because the doAfterBody() method reads the value from the buffer. EVAL_BODY_INCLUDE evaluates the body but doesn't buffer it.
After you've changed the tag handler class, make sure you restart the web container (or just the application, if your container supports that), to ensure that you're using the new version of the class. And don't forget to actually install the new version as well ;-) I've spent many hours pulling my hair just to realize that I was still using an old version of a class.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic