• 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:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Retrieve Images from oracle  RSS feed

 
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 !
 
Bartender
Posts: 19732
92
Android Eclipse IDE 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
Ranch Hand
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
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!