• 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

get image from database

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i want to display an image on my jsp. The path of the image is stored in the database in varchar type. There is a servlet which fetch the path from the database and gives it to the jsp. so now the problem is how i will use that path in jsp to show that image. please help me.
Thanhx in advance.
 
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where are images stored? Is path referring to file system on your server?
 
Sachin Kadian
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ya the images are stored on the server and there is the complete path in database.
 
Piyush Mangal
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which web server you are using.

If using tomcat, you can map physical path to logical path by modifing configuration file server.xml and insert following text into Host element:

<context crosscontext="true" docbase="c:\\temp\imgService" path="/imgService"></context>

 
Sachin Kadian
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ya i am using tomcat. can you please tell me how i can do so ? can you please give me any example..?
 
Piyush Mangal
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


In the above example, physical path c:\\temp\imgService is mapped to /imageService so if you have a image named image1.jpg in c:\\temp\imgService , you can refer the same in
your html as http://localhost:8080/imageService/image1.jpg .

Note : Assuming you are running tomcat on localhost and on port 8080.
 
Sheriff
Posts: 67746
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
I don't see what the big deal is. If you have the URL to the image, just use it in the image tag like any other HTML page.
 
reply
    Bookmark Topic Watch Topic
  • New Topic