Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • 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:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Is there an alternative to printing content directly from a tag handler class?  RSS feed

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

My custom tag takes a string of keywords as a parameter and uses these to fetch a list of items from a web service. I want to print the list to the page as a HTML list. The obvious thing to do would be to iterate over the list in my tag handler class and use the JspWriter to write the items to the page. But isn't there an alternative? I don't like the idea of writing HTML code from Java. Wouldn't it be possible to use my custom tag to somehow make the list of items available in my JSP, so I can iterate over it with JSTL?

Thanks
 
Author and ninkuma
Marshal
Posts: 66797
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wrote this article about doing something similar for JSP 1.2 (prior to tag files being introduced in JSP 2.0) at http://radio.javaranch.com/bear/2005/01/26/1106722509000.html

I nicknamed these "taglets".

It may be useful to adapt to what you want to do.

Or... you could invert it and use a tag file which invokes beans to do the Java stuff.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!