Since you did not mention your db structure for storing the image, I would think that you store it in blob type.
Part 1 : ControllerClass
After extracting the image from db, then encode this image with Base64.encode and map this image to your jsp (using java.util.map ).
Map<String, Object> model = new HashMap<String, Object>(); model.put("myImage", Base64.encode(MyImage)); //MyImage (datatype 'byte[]') is the image retrieved from DB return new ModelAndView("display", model); //display is the name of jsp on which you want to display image
Part 2 : JSP
Then map it to JSP by decoding the byte array,
<img id="myImg" name="myImg" src="data:image/jpg;base64,<c:out value='${myImage}'/>" >
source share