How to Display Image in Jsp Using Spring | Code Factory

Reference Link : Link

Donate : Link

Method 01 : Using Controller Method

Jsp

Controller

Util

Method 02 : Using base64

Jsp

Controller

Util

byte[] encoded = Base64.encodeBase64(fileBytes);
String encodedString = new String(encoded);
return encodedString;
} catch (Exception e) {
e.printStackTrace();
} finally {
if(byteArrayOutputStream != null) {
byteArrayOutputStream.close();
}
if(fileInputStream != null) {
fileInputStream.close();
}
}
return new String();
}