[Solved] How to display an image using inputstream in servlets?


You need write the image as a byte array to the response’s output stream. Something like this:

byte[] imageBytes = getImageAsBytes();
response.setContentType("image/jpeg");
response.setContentLength(imageBytes.length);
response.getOutputStream().write(imageBytes);

Then in you JSP you just use a standard img element:

<img src="url to your servlet">

Source: https://stackoverflow.com/a/1154279/1567585

solved How to display an image using inputstream in servlets?