Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Retrieve Images from oracle

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have stored image files in a database. Is there any way to display that image in a web browser by querying the database?
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No way !
 
Saloon Keeper
Posts: 22492
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Author
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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();
}
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
And then the entire population worshiped me like unto a god. Well, me and this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic