• Post Reply Bookmark Topic Watch Topic
  • New Topic

SimpleTagSupport question  RSS feed

 
Edward Chen
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have two questions about SimpleTagSupport.

=============
<myTag:loop> hello world </myTag:loop>
in doTag()
out = getJspContext().getOut();
for(int i=0; i<10;i++){
getJspBody().invoke( out );
}
=================
"getJspBody().invoke( out )" mean: get body content ("hello world") and put them into out object. Is this understanding right? it look like weird.

But how we want to change the body content and loop ? how we can change "hello world" to uppercase and loop 10 times ?

Thanks
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
invoke takes a java.io.Writer. One such subclass of Writer is StringWriter, which allows you to evaluate the JSPFragment to a String. At that point, you can convert it to uppercase or do whatever you want with it, eventually sending it to "out".
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!