Hi,
I am reading a file and then try to pass it as an output of a
Servlet response as follows:
ServletOutputStream out = response.getOutputStream();
File file = new File("somelaocation\\image1.jpeg");
response.setContentType("image/jpeg");
response.setHeader("Content-Disposition","inline");
FileInputStream in = new FileInputStream(file);
byte[] bytes = new byte[10000];
// Read in file and at the same time write the stream to the resposne.
while (true) {
int count = in.read(bytes);
if (count == -1)
break;
out.write(bytes, 0, count);
}
Now I have to pass many images to the output. So how is that accomplished?
I just tried a very RAW way of doing it (i.e by reading another file and passing it out again ) but it just doesnt work:
file = new File("someImage/image2.jpeg");
in = new FileInputStream(file);
byte[] bytes2 = new byte[10000];
while (true) {
count = in.read(bytes2);
if (count== -1)
break;
out.write(bytes2, 0, count);
}
Please advice. It only passes the first image.BOTH the images do not come SIMULTANEOUSLY! Matter is crucial.
Thanks in advance,
MD
[ April 08, 2005: Message edited by: milan doshi ]