aspose file tools*
The moose likes JSP and the fly likes get image from database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "get image from database" Watch "get image from database" New topic
Author

get image from database

Sachin Kadian
Ranch Hand

Joined: Jan 24, 2012
Posts: 33
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

Joined: Jan 22, 2007
Posts: 196
Where are images stored? Is path referring to file system on your server?
Sachin Kadian
Ranch Hand

Joined: Jan 24, 2012
Posts: 33
ya the images are stored on the server and there is the complete path in database.
Piyush Mangal
Ranch Hand

Joined: Jan 22, 2007
Posts: 196
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

Joined: Jan 24, 2012
Posts: 33
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

Joined: Jan 22, 2007
Posts: 196


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

Joined: Jan 10, 2002
Posts: 60050
    
  65

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: get image from database
 
Similar Threads
image uploading in jsp
How browse a URL from local disk
How can i randomly viewing image on jsp from the database
thumbnail in jsp
how to retrieve image in jsp page from a seperate folder.