• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to display image in JSP from oracle

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
i have stored..the path of images in oracle..and i need to retrieve image in JSP through that path stored in oracle.
how do i do it?
please let me know. its urgent.
chintan
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Chintan Shah:

please let me know. its urgent.



Please read this in order to understand why putting this phrase in your post may actually prevent people from answering.
[ March 21, 2006: Message edited by: Bear Bibeault ]
 
Chintan Shah
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
alright i understood..sorry about that..
 
Bear Bibeault
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No prob, just trying to help you make the most of Javaranch as a resource.
 
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The way I would do this, is to run my query to get the image paths, and if they are related to something bigger like a book or product of some sort, I would store them into a bean along with the rest of the individual product's information.

I would then send the beans back, typically inside an ArrayList, in the response to the JSP page. The JSP page would then have to unpack the beans from the ArrayList and then using the appropriate JSP code to display the image.

For example: <IMG SRC="<%=myProductBean.getImagePath()%>">
where myProductBean is one of the beans, and getImagePath() is a method defined in the bean class.

Hope that helps!
[ March 21, 2006: Message edited by: Jason Kwok ]
 
Bear Bibeault
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Passing the image data to the JSP will serve no purpose (and in an ArrayList? I don't see how that would work).

The image data would never be sent to the JSP which has no means of dealing with it. Rather, the JSP should render an img tag along the lines of



Then, an image serving servlet would fetch the image data from the DB (preferably delegating the task to a class or bean that's smart about caching the data) and send the image data as the response after setting the appriopriate MIME headers.
[ March 21, 2006: Message edited by: Bear Bibeault ]
 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bear,

I think he is storing the path (as varchar) and the not actual image (not LOBs) to the Oracle.
So I think retrieving it was correct.
But the care has to be taken for converting the physical to the context path.

Originally posted by Bear Bibeault:
Passing the image data to the JSP will serve no purpose (and in an ArrayList? I don't see how that would work).

The image data would never be sent to the JSP which has no means of dealing with it. Rather, the JSP should render an img tag along the lines of



Then, an image serving servlet would fetch the image data from the DB (preferably delegating the task to a class or bean that's smart about caching the data) and send the image data as the response after setting the appriopriate MIME headers.

[ March 21, 2006: Message edited by: Bear Bibeault ]

 
Bear Bibeault
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Dilip Kumar Jain:
I think he is storing the path (as varchar) and the not actual image (not LOBs) to the Oracle.



Ah, yes, upon re-reading I think you are correct.

In that case, it depends what the OP means by "path"? Is it the URL of the image, or the file system path? In the latter case, either the path must be converted to the corresponding URL (assuming that the file path is mapped as appropriate for web server access), or we're back to a servlet to read the file and serve the data.
 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Chintan,

Typically this kind of problems are solved by keeping the imgPath as context level variable and corresponding image name is picked up from the oracle DB in your case and simple pass the

u store the images in certain folder on the server where the application is runing

put the path in the ServletContext and retrieve the same in the jsp and build ur imagepath accordingly by appending the image name retrived from the DB and pass the imagepath.

<img src="<%=imagePath%>">
 
Chintan Shah
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey, thanks to everybody, for your guidance
ya, i stored the actual image path in oracle db..as varchar
then i passed query, retrieved path in String variable in JSP and then displayed it through imgsrc in JSP.
Well, thanks once again for all of your help
i am indeed thankful to every one of you.
Sorry..once again..about urgent thing.
chintan
 
Clowns were never meant to be THAT big! We must destroy it with this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic