Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > JSP Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old August 16th, 2004, 12:00 AM
Authorized User
 
Join Date: Apr 2004
Location: , , .
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to coitri Send a message via MSN to coitri Send a message via Yahoo to coitri
Default 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.


Reply With Quote
  #2 (permalink)  
Old August 23rd, 2004, 07:13 AM
Friend of Wrox
 
Join Date: Jul 2004
Location: , , India.
Posts: 345
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to gokul_blr Send a message via Yahoo to gokul_blr
Default

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


Reply With Quote
  #3 (permalink)  
Old August 30th, 2004, 10:42 AM
Authorized User
 
Join Date: Apr 2004
Location: , , .
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to coitri Send a message via MSN to coitri Send a message via Yahoo to coitri
Default

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?

Reply With Quote
  #4 (permalink)  
Old September 1st, 2004, 02:30 AM
Friend of Wrox
 
Join Date: Jul 2004
Location: , , India.
Posts: 345
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to gokul_blr Send a message via Yahoo to gokul_blr
Default

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.




Reply With Quote
  #5 (permalink)  
Old September 1st, 2004, 02:31 AM
Friend of Wrox
 
Join Date: Jul 2004
Location: , , India.
Posts: 345
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to gokul_blr Send a message via Yahoo to gokul_blr
Default

Check, What Tom says :

http://asktom.oracle.com/pls/ask/f?p...D:239814548726

Reply With Quote
  #6 (permalink)  
Old September 3rd, 2004, 12:34 AM
Authorized User
 
Join Date: Apr 2004
Location: , , .
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to coitri Send a message via MSN to coitri Send a message via Yahoo to coitri
Default

yeah, thanks!
But I want to display stored images on the JSP page.

Reply With Quote
  #7 (permalink)  
Old September 12th, 2004, 05:33 PM
Friend of Wrox
 
Join Date: Jul 2004
Location: , , .
Posts: 204
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.

Reply With Quote
  #8 (permalink)  
Old September 21st, 2004, 07:17 AM
Authorized User
 
Join Date: Sep 2004
Location: , , .
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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..
Reply With Quote
  #9 (permalink)  
Old September 21st, 2004, 08:53 AM
Friend of Wrox
 
Join Date: Jul 2004
Location: , , .
Posts: 204
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.

Reply With Quote
  #10 (permalink)  
Old September 21st, 2004, 08:55 PM
Registered User
 
Join Date: Sep 2004
Location: ningbo, , China.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to display pictures on JSP page? Kisat JSP Basics 1 November 3rd, 2008 09:02 PM
JSP page not display data coming from socket ashvinm JSP Basics 0 February 20th, 2008 02:10 AM
Display many pictures NBM Java GUI 0 September 3rd, 2006 07:54 AM
How to display Vietnamese Unicode on JSP page? minhpx JSP Basics 4 May 19th, 2006 12:16 AM



All times are GMT -4. The time now is 11:52 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.