Hi Ben,
I wrote some code based on your example, but it does not work quite right.
The image fills the entire browser window and the html is somehow kicked out of the response buffer.
I place this code in the response html:
<img border="1" align="middle" src="profile001.jpg">
This code is called by a
servlet to inject the picture into the response stream. It does send the pic to the browser, but it steps all over the html used to display it:
private void streamImg(HttpServletResponse response)throws ServletException, IOException{
response.setContentType("image/jpg");
response.setHeader("Content-Disposition",
" inline; filename=" + "profile001.jpg");
BufferedInputStream bin = new BufferedInputStream(new FileInputStream("C:/a/profile001.jpg"));
ServletOutputStream sos = response.getOutputStream();
byte[] buffer = new byte[4 * 1024];
int data = 0;
while((data = bin.read(buffer)) != -1){
sos.write(buffer, 0, data);
}
sos.flush();
bin.close();
}