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 Generating an Image in Custom Tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Generating an Image in Custom Tag" Watch "Generating an Image in Custom Tag" New topic
Author

Generating an Image in Custom Tag

Pete Hever
Greenhorn

Joined: Jun 10, 2004
Posts: 1
Hi guys,

I'm trying to generate an image from a byte array and then display it in an iterator tag. The trouble is that the tag doe not seem to write the data until it has finished iteration, so I just get the image of the last item repeated over and over.

Here is the iterator tag:


The image is generated by a JSP named generateImage.jsp and is referenced by the tags.

Here is the JSP code to convert the byte array taken from the iterated item:


The code does work, in that it outputs a byte array as an image (or outputs a "No image available" image from the file system if one is not specified), but it does not retain the info of each iterated item, only the last one. The result is that every iterated item output on the page has the same image.

Does anyone know how I could get around this, either by a different approach or by finding a way to generate the JSP file for each separate iteration.

Apologies if this is somewhat vague, any info or comments would be greatly appreciated. Thanks.


Peter Hever
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60752
    
  65

It is pretty vague. A few questions:

1) Why a JSP to generate the image? A servlet would make much more sense. JSPs are geared towards creating text responses. The fact that there's nothing but Java in your JSP should be clue that you're using a hammer to drive a screw.

2) What distinguishes each iteration? There seem to be no parameters that change.

3) I'm not familiar with the mtag set. Is it not time to adopt the JSTL for this sort of thing?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
 
subject: Generating an Image in Custom Tag
 
Similar Threads
Image loading problem
trouble with remove item fro shopping cart
Thumbnail
printing images in jsp
upload file in jsp