简体   繁体   中英

Display image from response

I have write the image into httpresponse , I defined the contentType for the image.

response.getOutputStream().write(imageBytes);
response.getOutputStream().flush();

What is the syntax to display this image in jsp?

You can use base64 encoding for this. For this you'll need to encode it as base64 on the server side and embed that on client side as -

<img src="data:png;base64,base64_encoded_image_here"> 

Of course, png can be replaced with appropriate mime_type. The downside it that the image will be part of the HTML content. But there won't be a separate HTTP request for this image.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM