• 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
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Bear Bibeault
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • salvin francis
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
Bartenders:
  • Jj Roberts
  • Carey Brown
  • Scott Selikoff

Eduardo Mock Exam : No. 24

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Given a tag handler defined with <bodycontent>JSP</bodycontent> which implements TagSupport and ONLY overrides doAfterBody with the following lines:
public int doAfterBody() throws JspException {
try { pageContext.getOut().print(� how are you? �);}catch(IOException e) {}
return SKIP_BODY;
}
What will be the result of a jsp with the following part?
<prefix:sufix>
<i>Hello</i>
</prefix:sufix>
1) The jsp page will print: Hello
2) The jsp page will print: Hello how are you?
3) The jsp page will print: how are you? Hello
4) The jsp won't print anything.
The answer is :
4) The jsp won't print anything.
TagSupport.doStartTag by default returns SKIP_BODY and as it is not overriden the body is ignored.
As I remembered that TagSupport doesn't
have doAfterBody, we have to implement
BodyTagSupport... please correct me if
I am wrong.
And what is the different between
JSP 1.1 & JSP 1.2 ?
It seems like I studied JSP 1.1 a lot,
and there are some big different..
Thx..
 
Ranch Hand
Posts: 8943
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Since TagSupport does not call doAfterBody method the JSP will print blank since doStartTag returns SKIP_BODY by default and there is no doEndTag method also defined ..the method DoAfterBody is just like any other method which has no role to play during the time the tag gets executed..

Originally posted by Michael Santosa:
Given a tag handler defined with <bodycontent>JSP</bodycontent> which implements TagSupport and ONLY overrides doAfterBody with the following lines:
public int doAfterBody() throws JspException {
try { pageContext.getOut().print(� how are you? �);}catch(IOException e) {}
return SKIP_BODY;
}
What will be the result of a jsp with the following part?
<prefix:sufix>
<i>Hello</i>
</prefix:sufix>
1) The jsp page will print: Hello
2) The jsp page will print: Hello how are you?
3) The jsp page will print: how are you? Hello
4) The jsp won't print anything.
The answer is :
4) The jsp won't print anything.
TagSupport.doStartTag by default returns SKIP_BODY and as it is not overriden the body is ignored.
As I remembered that TagSupport doesn't
have doAfterBody, we have to implement
BodyTagSupport... please correct me if
I am wrong.
And what is the different between
JSP 1.1 & JSP 1.2 ?
It seems like I studied JSP 1.1 a lot,
and there are some big different..
Thx..

 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As I remembered that TagSupport doesn't
have doAfterBody, we have to implement
BodyTagSupport... please correct me if
I am wrong.

That is not true.
TagSupport does have doAfterBody. doAfterBody is defined in IterationTag interface and TagSupport implements InterationTag interface. Hence it must have a default implementation for the doAfterBody method, which returns a SKIP_BODY.
And what is the different between
JSP 1.1 & JSP 1.2 ?
It seems like I studied JSP 1.1 a lot,
and there are some big different

Yes, there are bid differences. You do have to follow JSP.1.2 version on this.
regds.
- madhav
 
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i didn't get this one at all.
i have tried to run it, and if i use TagSupport i get a compilation error. It runs with BodyTagSupport only and outputs "Hello"...How come?
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if i use TagSupport i get a compilation error
When you used TagSupport, what did you return from doStartTag() and what was the compilation error?
- madhav
[ May 01, 2002: Message edited by: Madhav Lakkapragada ]
 
incandescent light gives off an efficient form of heat. You must be THIS smart to ride this ride. Tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic