Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within OCPJWCD
Search Coderanch
Advance search
Google search
Register / Login
Forums
Register
Login
Certification
»
Web Component Certification (OCEJWCD)
JavaBeat question, SKIP_BODY
Chandra Bhatt
,
Ranch Hand
Jul 29, 2007 01:16:00
(0 cow)
(0 skulls)
+Pie
Number of slices to send:
Send
11.Consider the tag handler class shown in exhibit. What will be printed when the above tag is used as follows in a jsp page: Hello <mylib:mytag> World!</mylib:mytag> public class MyTag extends TagSupport { public int doAfterBody() { try { pageContext.getOut().println("In doAfterBody()"); } catch(Exception e) { } return SKIP_BODY; } } Select 1 correct option. [B]A.Hello[/B] ANSWER B.Hello World! C.Hello In doAfterBody() World! D.Hello In doAfterBody() E.None of the above.
Could anybody please focus on this, why the output is Hello?
SOURCE
Thanks,
Vassili Vladimir
,
Ranch Hand
Jul 29, 2007 02:50:00
(0 cow)
(0 skulls)
+Pie
Number of slices to send:
Send
Hi,
The output is Hello because you did not override the doStartTag() method, which its default return value is SKIP_BODY, so, the body will not be be evaluated.
Best of luck ...
Remko Strating
,
Ranch Hand
Jul 29, 2007 02:51:00
(0 cow)
(0 skulls)
+Pie
Number of slices to send:
Send
Because MyTag doesn't override the doStartTag() method.
The default behavior of the doStartTag is that there is no body evaluated.
You should
add the following code for getting output
public int doStartTag() throws JspException { return EVAL_BODY_INCLUDE; }
Chandra Bhatt
,
Ranch Hand
Jul 29, 2007 03:12:00
(0 cow)
(0 skulls)
+Pie
Number of slices to send:
Send
Thanks Vassili & Remko!
I got the that.
You rock dude.
Thanks,
Michael Ku
,
Ranch Hand
Jul 29, 2007 13:51:00
(0 cow)
(0 skulls)
+Pie
Number of slices to send:
Send
It is always a good idea to set up the code in question and run it to see what is happening and why. You can even step thru the code in debug mode.
I did this when preparing for the exam and I learned so much that the exam was a breeze...
Chandra Bhatt
,
Ranch Hand
Jul 29, 2007 21:21:00
(0 cow)
(0 skulls)
+Pie
Number of slices to send:
Send
I agree with you Michael!
Thanks,
Post by:
autobot
A lot of people cry when they cut onions. The trick is not to form an emotional bond. This tiny ad told me:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
reply
This thread has been viewed 867 times.
Similar Threads
doubts in CustomTags
Mock Exam Question.
Doubt on Tag Files
Taghandler doubt
jdiscuss mock exam question
More...
All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 01:11:25
.