• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

how to show Blob image from database using jstl  RSS feed

 
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
 
author & internet detective
Sheriff
Posts: 38569
659
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
 
Sheriff
Posts: 23713
50
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.
 
Sheriff
Posts: 21459
96
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.....
 
Author and ninkuma
Marshal
Posts: 66806
168
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: 21459
96
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: 66806
168
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: 21459
96
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: 66806
168
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!