I have a InputStream of an image in string format. How to display that image in the browser using servlets?
This is the (start of the) string.
/9j/4AAQSkZJRgABAgAAAQABAAD/4QDVRXhpZgAASUkqAAgAAAAIABIBAwABAAAAAQAAABoBBQABAAAAbgAAABsBBQABAAAAdgAAACgBAwABAAAAAgAAADEBAgANAAAAfgAAADIBAgAUAAAAiwAAABMCAwABAAAAAQAAAGmHBAABAAAAnwAAAAAAAABkAAAAAQAAAGQAAAABAAAAQ...
You need write the image as a byte array to the response’s output stream. Something like this:
Then in you JSP you just use a standard img element:
Source: https://stackoverflow.com/a/1154279/1567585