aspose file tools*
The moose likes Servlets and the fly likes Retrieve Images from oracle Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Retrieve Images from oracle" Watch "Retrieve Images from oracle" New topic
Author

Retrieve Images from oracle

Maheshwari J
Greenhorn

Joined: Aug 13, 2001
Posts: 3
I have stored image files in a database. Is there any way to display that image in a web browser by querying the database?
Nathan KV
Greenhorn

Joined: Aug 09, 2001
Posts: 25
No way !
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16305
    
  21

I think that an <IMG SRC="gifserver.jsp?imagename=a_db_key"> type of tag would work. Your "gifserver.jsp" would have to extract the data from the database and return a response type (MIME type) of a GIF image.


Customer surveys are for companies who didn't pay proper attention to begin with.
chanoch wiggers
Author
Ranch Hand

Joined: May 24, 2001
Posts: 245
A servlet is actually much better suited to doing this kind of work. Here is some example code I found:
public void doGet (HttpServletRequest req, HttpServletResponse res)
�������throws ServletException, IOException {
�������OutputStream out = res.getOutputStream();
�������String fileName = req.getParameter("image");
�������res.setContentType("image/jpeg");
// I'm not sure this line is quite right
String realPath = context.getRealPath(image);
�������FileInputStream in = new FileInputStream(readPath);
// i'm also not convinced this is the best
// way of doing this
�������int i;
�������while ((i = in.read()) != -1) {
�����������out.write(i);
�������}
�������in.close();
�������out.close();
}

chanoch<p><a href="http://www.amazon.com/exec/obidos/ASIN/1861007736/" target="_blank" rel="nofollow">Author of Professional Apache Tomcat</a></p>
Raghav
Greenhorn

Joined: Jul 24, 2001
Posts: 14
Originally posted by Maheshwari J:
I have stored image files in a database. Is there any way to display that image in a web browser by querying the database?

Hi,
I think these links show how to insert and retrive images from a database ,i hope this will be helpful for u
http://developer.java.sun.com/developer/onlineTraining/Database/JDBC20Intro/exercises/BLOBPut/index.html
http://developer.java.sun.com/developer/onlineTraining/Database/JDBC20Intro/exercises/BLOBGet/index.html
regards
raghav
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Retrieve Images from oracle