This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes retreiving images from the database and dispaly them on HTML file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "retreiving images from the database and dispaly them on HTML file" Watch "retreiving images from the database and dispaly them on HTML file" New topic
Author

retreiving images from the database and dispaly them on HTML file

maher dabbas
Greenhorn

Joined: Dec 02, 2001
Posts: 26
Hi all.
I've retreived stored as Blob from Oracle database, and get it as binary stream and write it into a file as follows
a1=res.getBlob("item_pic");
long len = a1.length();
int len2=(int)len;
InputStream input=a1.getBinaryStream();
data=new byte[len2];
int byte_read=input.read(data);

String p="C:\\tomcat\\webapps\\test\\jsp\\";
File temp=new File(p,"temp.jpg");
fos=new FileOutputStream(temp);
fos.write(data);
fos.close();
the image is stored in a .jpg file an i'm able to open it and view it with no problems,BUT, when i try to put this image in HTML file using
<img src="temp.jpg" > , i does not work!!!
the HTML file and the image are in the same folder, there is no corruption in the image , i'm able to open it and view it
can any body help me plz, this is driving me nuts!!!1

Regards.
Maher Dabbas
Qaiser Chaudhry
Greenhorn

Joined: Apr 25, 2001
Posts: 10
If the image is getting to the directory you want it to be in. Then instead of causing yourself the headache of changing and running the jsp, try just a simple HTML file and try to fix it from there first. It might just be a simple path or tag problem. When it's fixed, jost port your changes to the jsp.
 
Don't get me started about those stupid light bulbs.
 
subject: retreiving images from the database and dispaly them on HTML file
 
Similar Threads
OutOfMemoryError... Whats the solution?
Multiple File Save
How to set and get images in Oracle databse
Retreiving an image using JDBC
URL constructor Question