aspose file tools*
The moose likes Servlets and the fly likes urgent - display Image (binary) + html in single page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "urgent - display Image (binary) + html in single page" Watch "urgent - display Image (binary) + html in single page" New topic
Author

urgent - display Image (binary) + html in single page

sanjeev mehra
Ranch Hand

Joined: Feb 12, 2001
Posts: 93
Hi,

I am trying to present Image(binary) using HttpServletResponse.getOutputStream (), but I am not able to present <html> content with this image.
I would be thankful to you for your help & suggestions.

Thanks & Regards,
Sanjeev.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12785
    
    5
Stop - take a look at the source of any web page that has an image in it. What do you see? You see that the image data is not served with the HTML, instead there is an <img tag that has a src attribute which points to where the browser should obtain the image data. You can't create HTML plus image data in a single pass, the image has to come in a separate request.
If you want a servlet to serve binary image data, your HTML page must be generated with a <img src="URL that points to the servlet.
You are on the right track using an OutputStream - not a Writer.
Be sure to set the response content-type to match the image encoding. If possible you should also set the content-length.
Serving image and other binary resources comes up frequently, so do some searching.
Bill
sanjeev mehra
Ranch Hand

Joined: Feb 12, 2001
Posts: 93
thanks a lot I have done it same way. thanks for replying.

regards,
sanjeev.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: urgent - display Image (binary) + html in single page