Forums Register Login

Body Content Problem

+Pie Number of slices to send: Send
I am a bit confused about the Body Content,
here is the piece of codes :
int doAfterTag() throws JspTagException
{
BodyContent bc = getBodyContent();
bc.getEnclosingWriter().println("Test 123");
pageContext.getOut().print("Test 123");
...
So my question is what is the different
between :
bc.getEnclosingWriter().println("Test 123");
and
pageContext.getOut().print("Test 123");
?
And I test that :
bc.getEnclosingWriter().println("Test 123");
Only prints the data out dan doesn't change
the body.
The second question is :
What is the uses of :
out = pageContext.pushBody();
out = pageContext.popBody();
??
(I saw it on generated Servlet).
Does pushBody put the content of the body
into stack, and popBody get the body
again from the Stack ?
Thank you for the help.. I really appreciate it
[ April 26, 2002: Message edited by: Michael Santosa ]
+Pie Number of slices to send: Send
"pushBody()" pushes the current "out" object available to the JSP page on the stack and returns the "bodyContent" object that is eventaully passed on to the tag handler by invoking the "setBodyContent()" method.
bodyContent actually extends JspWriter and it simply provides a kind of play area for the BodyTag implementing handlers, where the body content can be manipulated without actually affecting the JspWRiter of the enclosing JSP page.
The actual content of the bodyContent can be obtained as a String using "getString()" method or as a Reader using the "getReader()" method or it can be written to a writer using "writeOut(Writer w)" method. To write to the client's response thr writeOut method has the enclosing JspWriter object which is obtained by calling the "getEnclosingWriter()" method.
I hope this helps you...
Curse your sudden but inevitable betrayal! And this tiny ad too!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 665 times.
Similar Threads
JSP Tags - Attributes passed returns NULL [SOS Please help]
A mock question on custom tags
what happens when doStartTag returns EVAL_BODY_BUFFERED?
Edurardo Cobian's mock exam answer correct for Question No 25
Can anyone explain this to me?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 07:40:34.