OutputStream outputStream = response.getOutputStream();
response.setHeader("content-type","image/jpeg");
Try reversing these two lines:
response.setHeader("content-type","image/jpeg");
OutputStream outputStream = response.getOutputStream();
It may be that when the output stream is retrieved that the header
lines are "fixed", although I thought that only happened when you
actually wrote to the output stream.
Also, I think the suggestion to check yuor image by writing to a local
file is a good idea just to make sure the image content is correct.
Finally, request the image url manually:
telnet host 80
GET /getphoto.jsp?photo_id=1 HTTP/1.0
<blank line>
to see if the header returned has the correct content-type.
HTH,
tim.