ServletOutputStream & browser download problem

Hi, i have tried to download an image from my browser, this is the code in my servlet. I think this code would send a byte stram to my browser.

response.setContentType("image/jpg");

response.setDateHeader("Expires", 0);

response.setHeader("Cache-Control","no-cache");

byte[] content ....// my jpg image

ServletOutputStream sos = response.getOutputStream();

sos.write(content);

sos.flush();

sos.close();

i've this problem, all the images that i try to donwload have the same size and they have not a jpg extension. Any advise?

thnx

[771 byte] By [m.lipreria] at [2007-11-26 22:40:45]
# 1
You just need to set the content length and the filename in the response.
BalusCa at 2007-7-10 11:54:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
ok, i've added this string:response.setContentLength(content.length);how can i do to add the name file propiety?Have i to put all the header propietes before all my html code, is it right?
m.lipreria at 2007-7-10 11:54:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
[url= http://www.google.com/search?q=httpservletresponse+set+filename]Click here[/url].
BalusCa at 2007-7-10 11:54:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...