• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get tag body using Simple Tags?

 
Gowher Naik
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HFS&JSP says that if you want to access to actual content of tag body pass
Writer to invoke()
getJspBody().invoke(java.io.Writer)
But i am not able to understand how to code it
Please help me
Thanks.
 
Renu Radhika
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public class MySimpleTag extends SimpleTagSupport {
public void doTag() throws JspException, IOException {
StringWriter sw = new StringWriter();
getJspBody().invoke(sw);
getJspContex().getOut().write(sw.toString());
}
}


This is given under this

http://java.boot.by/wcd-guide/ch10s04.html
Please check.I have not tried it out
 
Gowher Naik
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks
yes it works.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic