-1

I am stored an image in postgres sql as bytea[] field.That is in byte format.I want to view the perfect image into my jsp page after storing the image.Please, point me to the solution or some ways to achieve this requirement.

StanislavL
  • 56,971
  • 9
  • 68
  • 98
Gayathri Rajan
  • 369
  • 1
  • 6
  • 18

1 Answers1

1

Covert your image to Base64:

String imageBase64 = new String(Base64.getEncoder().encode(imageByteArray))

Note that Base64 class is coming from java.util package. If you not using JDK 8 you can easily find an alternative to do that.

Then in your JSP page:

<img src="data:image/png;base64,${imageBase64}" />
Paulius Matulionis
  • 23,085
  • 22
  • 103
  • 143