Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

get image from database

 
Sachin Kadian
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • 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.
 
Piyush Mangal
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
  • 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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64631
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic