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.
Asked
Active
Viewed 1,952 times
-1
-
5http://stackoverflow.com/questions/5243726/how-to-display-an-image-in-jsp – wawek Aug 11 '15 at 11:04
1 Answers
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
-
Thank you for the reply.I tried the code.But problem is the same. – Gayathri Rajan Aug 11 '15 at 11:44
-
This is the right way to do it. Please amend your question with the details of what exactly is not working. – Paulius Matulionis Aug 11 '15 at 11:46
-
Thank you sir for the reply...I got the answer.Only one change is there to view the image.
– Gayathri Rajan Aug 11 '15 at 12:02