Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt on Tag Files

 
Padma priya Gururajan
Ranch Hand
Posts: 437
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 terBody() {
try {
pageContext.getOut().println("In doAfterBody()");
}
cdoAfatch(Exception e) { }
return SKIP_BODY; }}
 
Srinivasan thoyyeti
Ranch Hand
Posts: 557
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
priya,

wake up. you are typing something in your dreams also.
 
Padma priya Gururajan
Ranch Hand
Posts: 437
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I want to know how the output can be Hello and why not Hello World?
With regards,
Padma priya N.G.
 
Srinivasan thoyyeti
Ranch Hand
Posts: 557
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
priya,

I don't know whether you are able to see your code posted correctly.
But for me its greek and latin.

According to your result in the second post,

doStartTag() returns SKIP_BODY, then Body won't be executed.
it will reach doEndTag().


see the lifeCycle carefully once again.
 
khushhal yadav
Ranch Hand
Posts: 242
Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Priya

It will be because you are not overriding doStartTag().
And in super class i.e. TagSupport, the return type of doStartTag() is Tag.SKIP_BODY. So your body won't be executed, and doAfterBody() won't get a chance to execute.

Hence, you are getting "Hello" as output not as "Hello World".

I think I interpret your question to some extent.

Buttttt seriously as per Srinivasan be little conscious, while you are posting.

Regards,
Khushhal
 
Padma priya Gururajan
Ranch Hand
Posts: 437
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Sorry. It is doAfterBody tag and not doStart tag!!
With regards,
Padma priya N.G.
 
Srinivasan thoyyeti
Ranch Hand
Posts: 557
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
khushhal yadav,

Now i understood her posted after seeing your reply.

The answer is same but the catch is different. .Good one.
 
Padma priya Gururajan
Ranch Hand
Posts: 437
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everybody,
I got the answer correct. Thanks.
With regards,
Padma priya N.G.
 
Cristiano Sganzerla
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is not tag file padmapriyagururajan !!
 
Padma priya Gururajan
Ranch Hand
Posts: 437
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Yes. It is a question related to custom tags.
Padma priya N.G.
 
Raghavan Muthu
Ranch Hand
Posts: 3381
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by padmapriyagururajan priya:
Hi,
Yes. It is a question related to custom tags.
Padma priya N.G.


Though it may have a little relevance, its better to give an appropriate title to the post Priya.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic