File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Is there an alternative to printing content directly from a tag handler class? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Is there an alternative to printing content directly from a tag handler class?" Watch "Is there an alternative to printing content directly from a tag handler class?" New topic
Author

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

ruben depuben
Greenhorn

Joined: Feb 19, 2009
Posts: 6
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
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60082
    
  65

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is there an alternative to printing content directly from a tag handler class?
 
Similar Threads
Page Breaks...
Using JSTL forEach with a custom tag
Need help with Drop Down list
How to display records in Grid view format in Jsp
struts Action for asynchronous HTTP processing