Win a copy of hapi.js in Action this week in the HTML, CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to show Blob image from database using jstl

 
isslam akkilah
Greenhorn
Posts: 11
Java Netbeans IDE PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
I got this tutorial link and it work fine but when i try to select the picture using JSTL tags it shows picture with broken links cause it's Blob
here is the code to show the picture



my question is can it be using jstl and is there any tuts
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35524
402
Eclipse IDE Java VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need a separate server request for the image. For example, you could have a servlet that takes an image id and returns the binary image. That way your "main" JSTL just needs to output the URL for that servlet request.
 
isslam akkilah
Greenhorn
Posts: 11
Java Netbeans IDE PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
do you have any link that you think it's good and correct way
 
Paul Clapham
Sheriff
Posts: 21700
33
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes indeed, we have a page right here on the Ranch all about that. "Image Servlet" is the usual name of the thing you want to produce and our page about that is here: https://coderanch.com/wiki/660125/Image-Servlet

You'll see there's a lot of details you have to deal with but it's all pretty straightforward once you work through it. Let us know if you have problems, that's what we're here for.
 
Rob Spoor
Sheriff
Posts: 20800
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne Boyarsky wrote:You need a separate server request for the image. For example, you could have a servlet that takes an image id and returns the binary image. That way your "main" JSTL just needs to output the URL for that servlet request.

Most modern browsers support inline data as well. The source would be data:<mime type>;base64,<base64 data>. For example (truncated), data:image/png;base64,iVBORw0KGgoA.....
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65417
100
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bearing in mind that that's not generally recommended (no caching, etc...)
 
isslam akkilah
Greenhorn
Posts: 11
Java Netbeans IDE PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i solve it using img tag and the context path thing inside the src??
 
Rob Spoor
Sheriff
Posts: 20800
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Bearing in mind that that's not generally recommended (no caching, etc...)

Unless if the image occurs only on the page itself, and the page itself is already cached.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65417
100
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Spoor wrote:
Bear Bibeault wrote:Bearing in mind that that's not generally recommended (no caching, etc...)

Unless if the image occurs only on the page itself, and the page itself is already cached.


Unlikely in a Java web app where caching is usually disabled.
 
Rob Spoor
Sheriff
Posts: 20800
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've seen enough html files being properly cached, and you can add your own caching as well. I had to add some of that manually a few times already.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65417
100
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My point applies to content that's not pure HTML such as JSPs (or other template-generated views), which comprise the majority of views in a Java web app.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!