Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

SimpleTagSupport question

 
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".
 
How do they get the deer to cross at the signs? Or to read this tiny ad?
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!