By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,851 Members | 1,729 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,851 IT Pros & Developers. It's quick & easy.

why I can't display a jpg Blob field in web?

P: n/a
hello,

I am retrieving the blob field with de following code:

----------
rs = st.executeQuery(sql);
if (rs.next()){
foto = rs.getBlob(1);
length = (int)foto.length();
InputStream in = foto.getBinaryStream();
buffer=foto.getBytes(0, length);
int bufferSize = 1024;
buffer = new byte[bufferSize];
while ((length = in.read(buffer)) != -1) {
miFicheroSt.write(buffer, 0, length);
}
}
----------

when I do:
<img src="../../tmp/<%out.println(nomFitxer);%>">

from a jsp file, it doesn't display a jsp.
It say that is not the correct format

Can you help me?

Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
You didn't post the query or the table definitions, let alone how you stored
the BLOB (AIV extender?). And whilst your post says jsp the subject say jpg.
And what your browser can render in an <img> is also unspecified. Finally,
web rendering isn't really a DB2 issue. Start at the beginning and post
sufficient details.

"asterix" <jo***********@urv.net> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
hello,

I am retrieving the blob field with de following code:

----------
rs = st.executeQuery(sql);
if (rs.next()){
foto = rs.getBlob(1);
length = (int)foto.length();
InputStream in = foto.getBinaryStream();
buffer=foto.getBytes(0, length);
int bufferSize = 1024;
buffer = new byte[bufferSize];
while ((length = in.read(buffer)) != -1) {
miFicheroSt.write(buffer, 0, length);
}
}
----------

when I do:
<img src="../../tmp/<%out.println(nomFitxer);%>">

from a jsp file, it doesn't display a jsp.
It say that is not the correct format

Can you help me?

Nov 12 '05 #2

P: n/a
Although nothing to do with DB2 and so off topic here, did you not
overwrite your "buffer" containing the image data bytes with an empty
1024 byte array when you did
buffer=foto.getBytes(0, length);
int bufferSize = 1024;
buffer = new byte[bufferSize];


Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.