• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Generating an Image in Custom Tag

 
Pete Hever
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65126
92
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic