Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: how to display image from DB table (blob format)
hi friends
i have store my image in mysql table(blob format) .i am using liferay portal 6.0.and i want to display this image on my portlet how to do it?
plz help.
i have store my image in mysql table(blob format) .i am using liferay portal 6.0.and i want to display this image on my portlet how to do it?
plz help.
The liferay's way is to create service.xml and portal-model-hints.xml and may be ext-spring.xml as well.
Hi,
I am facing same issues.
I am storing image as a blob in db. Now i need to disply that blob image in jsp.
How to resolve this.
I am facing same issues.
I am storing image as a blob in db. Now i need to disply that blob image in jsp.
How to resolve this.
Mahammad Ashik AI'm assuming that you know how to get the image out of the database, and which image format it is.
I am storing image as a blob in db. Now i need to disply that blob image in jsp.
In order to provide a URL for it, I'm assuming that you have a portlet (that contains your JSP). In that portlet, use a <portlet:resourceURL>, parameterize it with (e.g.) the image's id. In the portlet's serveResource method, use that id to find the appropriate image, set the content type and stream the image to the browser (resourceResponse.getOutputStream()).
Hi Olaf Kock ,
Thanks for your support
Thanks for your support
Hi,
I resolved this issues by below code.
<%
Blob blob= <fetch from DB>
int myblobLength = (int) blob.length();
byte[] myblobAsBytes = blob.getBytes(1, myblobLength);
String qrCodeDisplay = DatatypeConverter.printBase64Binary(myblobAsBytes);
%>
<div class="container text-center">
<img class="img-responsive" src="data:image/jpg;base64, <%=qrCodeDisplay%>"/>
</div>
I resolved this issues by below code.
<%
Blob blob= <fetch from DB>
int myblobLength = (int) blob.length();
byte[] myblobAsBytes = blob.getBytes(1, myblobLength);
String qrCodeDisplay = DatatypeConverter.printBase64Binary(myblobAsBytes);
%>
<div class="container text-center">
<img class="img-responsive" src="data:image/jpg;base64, <%=qrCodeDisplay%>"/>
</div>
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™