Displaying images on JSP using out.write(byte[])

Hi Friends

I have a requirement to show multiple images on a jsp in tabular form. Now these images are coming from database in form of byte[].

In my jsp im writing :

<%

OutputStream os = response.getOutputStream();

ArrayList images=(ArrayList)exp_Man.getImagesList(line_Id);

for(int i=0;i<images.size();i++){

%>

<tr><td>

<%

byte[] image=(byte[])images.get(i);

os.write(image);

os.flush();

%>

</td></tr>

<%

}

%>

The above code gives error that response.getOutputStream() is alreay open for this response. Am I doing something wronge, i dont know.

If im doing some mistake, ols do tell me.

Thanks in advance.

[779 byte] By [Neo2001a] at [2007-11-27 6:27:00]
# 1

You can set and write to the response only once.

Rather develop kind of an ImageServlet which independently streams the images.

You can find several examples here: http://www.google.com/search?q=imageservlet

Here is a nice example: http://balusc.xs4all.nl/srv/dev-jep-img.html

BalusCa at 2007-7-12 17:48:34 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...