473,321 Members | 1,877 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

Loading Image

please can anyone help me I? here is my code to load image from mysql and display it in jsp
<%@ page import="java.sql.*"%>

<%@ page import="java.io.*"%>


<% Blob image = null;

Connection con = null;

byte[ ] imgData = null ;

Statement stmt = null;

ResultSet rs = null;


try {

Class.forName("com.mysql.jdbc.Driver");

con = DriverManager.getConnection("jdbc:mysql://localhost/television","root","timo");

stmt = con.createStatement();

rs = stmt.executeQuery("select passport from remote where id = '4'");

if (rs.next()) {
imgData = rs.getBytes(1);

} else {

out.println("Display Blob Example");

out.println("image not found for given id>");

return;

}


// display the image

response.setContentType("image/gif");

OutputStream o = response.getOutputStream();

o.write(imgData);

o.flush();

o.close();

} catch (Exception e) {

out.println("Unable To Display image");

out.println("Image Display Error=" + e.getMessage());

return;

} finally {

try {

rs.close();

stmt.close();

con.close();

} catch (SQLException e) {

e.printStackTrace();

}

}

%>
but it's still given me error:
The Image "http://WebApplication/index.jsp" cannot be display because it contains error. I can precisely identify this error.
Dec 5 '11 #1
0 1517

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Irfan Akram | last post by:
Hi Guys, I asked this question yesterday, but have not yet received a suitable answer. I hope you guys can help me out. I want to load an image on to a web-page. The image is alreday stored in...
3
by: Bri | last post by:
AC97 on WinXP, Image control on a Form and on a Report. I have followed the advice on the following MVPS page: http://www.mvps.org/access/api/api0038.htm This states that after changing the...
1
by: agatha.life | last post by:
I did a javascript for the loading of images (I didn't want to have the images loaded in "on loading" because they are too many). The website is for a model and if you look at the codeof pages (...
2
by: brianflannery | last post by:
Greetings! My situation is this. I currently have a database of which in a form displays jpeg pictures (one at a time) which are linked to the db and stored in a separate folder. I have set up a...
0
by: atlkhan | last post by:
Hi I am loading bitmapdata from the library like this linkageId = "landscape"; myBitmapData = BitmapData.loadBitmap(linkageId); Than attach this bitmap image to a movie. mc =...
1
by: vjayis | last post by:
Hi I hav a page in which datas are displayed intially from the database. And using a link i m retriving datas from another page using ajax., it takes time and user might think tht nothing...
1
by: Phil Stanton | last post by:
Is there any way of stopping the cursor jumping to a point roughly in the middle of the screen when loading a new picture into an Image Control. The picture is linked and pulled from an external...
6
by: aaronkmar | last post by:
Trying to get a loading image to spin while the query is loading. I can get the data div to fade in, but I can't seem to figure out how to get the gif while the query is loading. I'm using two...
0
by: rishi goyal | last post by:
how to add image using in project which is loading image using LoadResPicture in vb6
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.