|
 |
JSP Basics Beginning-level questions on JSP. More advanced coders should post to Pro JSP. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the JSP Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
|
 |
|
|
 |
|

August 15th, 2004, 11:00 PM
|
Authorized User
|
|
Join Date: Apr 2004
Location: , , .
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
How to display pictures on JSP page?
Hi all, please give me your solution, thanks.
I have many pictures, stored in Oracle database (BLOB),
How to display them (pictures) on JSP page?
Thanks advance.
|

August 23rd, 2004, 06:13 AM
|
Friend of Wrox
|
|
Join Date: Jul 2004
Location: , , India.
Posts: 345
Thanks: 0
Thanked 1 Time in 1 Post
|
|
This could be helpful for you, (support from Oracle)
Working with LOBs and BFILEs
This chapter describes how you use JDBC and the oracle.sql.* classes to access and manipulate LOB and BFILE locators and data, covering the following topics:
Oracle Extensions for LOBs and BFILEs
Working with BLOBs and CLOBs
Working with BFILEs
http://download-west.oracle.com/docs...ob.htm#1000888
|

August 30th, 2004, 09:42 AM
|
Authorized User
|
|
Join Date: Apr 2004
Location: , , .
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks gokul_blr,
But it's not helpful for me!
I have a database, and there are many picture, stored in BLOB field.
I want to query and display them on the JSP page,
Any more idea to me?
|

September 1st, 2004, 01:30 AM
|
Friend of Wrox
|
|
Join Date: Jul 2004
Location: , , India.
Posts: 345
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Look at the suggestion :
----------------------------------------
declare
dirname varchar2(255);
v_filename varchar2(255);
begin
tool_env.getvar('DEMO60', dirname);
dirname := dirname || '\bin\bmp';
v_filename := get_file_name(dirname,NULL,
'All Files (*.*)|*.*|' ||
'JPEG Files (*.jpg)|*.jpg|' ||
'Bitmap Files (*.bmp)|*.bmp|' ||
'TIFF Files (*.tif)|*.tif|' ||
'CompuServe Files (*.gif)|*.gif|' ||
'PC Paintbrush Files (*.pcx)|*.pcx|' );
if v_filename is not null then
read_image_file(v_filename,'ANY','img_tab.img_tst' );
end if;
end;
------------------------------------------------
Forms 6i doesn't support BLOBs, change type to "long raw" and it should work
or you can create a similar procedure and load the images using SQL*Plus.
|

September 1st, 2004, 01:31 AM
|
Friend of Wrox
|
|
Join Date: Jul 2004
Location: , , India.
Posts: 345
Thanks: 0
Thanked 1 Time in 1 Post
|
|
|

September 2nd, 2004, 11:34 PM
|
Authorized User
|
|
Join Date: Apr 2004
Location: , , .
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
yeah, thanks!
But I want to display stored images on the JSP page.
|

September 12th, 2004, 04:33 PM
|
Friend of Wrox
|
|
Join Date: Jul 2004
Location: , , .
Posts: 204
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Got mySql solution from SunJava, would suggest you have a look there if your still stuck.
Assuming you are able to return the image into a recordset with something like:
String query = "select image from images where id =1";
Statement st = con.createStatement();
ResultSet rs = st.executeQuery(query);
rs.next();
The code youre really after goes something like this:
byte[] bytearray = new byte[4096];
int size=0;
InputStream sImage;
sImage = rs.getBinaryStream(1);
response.reset();
response.setContentType("image/jpeg");
response.addHeader("Content-Disposition","filename=getimage.jpeg");
while((size=sImage.read(bytearray))!= -1 )
{
response.getOutputStream().write(bytearray,0,size) ;
}
response.flushBuffer();
sImage.close();
The problem with this is that you cannot put it into a table etc. The original poster of the solution in the Sun forum 'included' the jsp containing the above in the table of a second jsp, which is what I do also.
|

September 21st, 2004, 06:17 AM
|
Authorized User
|
|
Join Date: Sep 2004
Location: , , .
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi angrycat,
ur solution enables me to display an image (stored as blob data type in mysql) on a jsp page..
However i cannot display the image(a gif image) in a table..
I followed ur instruction and included ur code(say Your_Code.jsp)in a second jsp page but only the image got displayed,not the table and its contents..
the sample code of second jsp page(say show.jsp) is as follows
<table>
<tr>
<td>Hello</td>
<td><%@include file="Your_Code.jsp"%></td>
OR
<td><jsp:include page="Your_Code.jsp" flush="true"/></td>
</tr>
</table>
the output of show.jsp is the gif image only without any html...
Kindly let me know how u implemented this functionality..
Thnx..
|

September 21st, 2004, 07:53 AM
|
Friend of Wrox
|
|
Join Date: Jul 2004
Location: , , .
Posts: 204
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Sorry,
I did not use includes, I simply used the page as the image source:
<td><img src="getImage.jsp"></td>
What I havent tested is passing different parameters to the jsp page from this link, thus retrieving multiple records from the database, but Im pretty sure it will work.
|

September 21st, 2004, 07:55 PM
|
Registered User
|
|
Join Date: Sep 2004
Location: ningbo, , China.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
in my opion, it is a mistake even if you did it succssfully.
the computer will make it as a static page and it won't interprete
it again.
|
Thread Tools |
Search this Thread |
|
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |