?
Solved

how to display some  pics in only one page. which saved in oracle .

Posted on 2003-03-09
8
Medium Priority
?
164 Views
Last Modified: 2010-04-01
to all :
how to display some  pics in only one page. which saved in oracle .
  i use this code :
PreparedStatement sql=con.prepareStatement("select * from blob_test WHERE
rno =13" );
ResultSet rs = sql.executeQuery();
rs.next();
InputStream in = rs.getBinaryStream("photo");
response.reset();
response.setContentType("image/bmp");
byte[] b = new byte[1024*1024];
int len;
while((len=in.read(b)) >0)
response.getOutputStream().write(b,0,len);
in.close();
rs.close();


but it just display only one photo in whole page and i want to the page
display more content,such as
other pictures,and some words.

how to control ? please give me some code or advice,
       with many thanks

handsome1234
0
Comment
Question by:handsome1234
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 92

Expert Comment

by:objects
ID: 8099247
Keep what you've got and modify it so it gets the photoid as a request parameter, and create a new page which uses it to display all your photos.

<%
PreparedStatement sql=con.prepareStatement("select rno from blob_test");
ResultSet rs = sql.executeQuery();
while (rs.next())
{
%>
<img src="GetPhotoServlet?id=<%= rs.getObject("rno") %>" >
<%
}
%>

0
 
LVL 14

Expert Comment

by:kennethxu
ID: 8099533
in your servlet use this:

String strRno = request.getParameter( "rno" );
int rno = 0;
if( strRno != null ) {
   try { rno = Integer.parseInt( strRno ); }
   catch( NumberFormatException e ) { strRno = null; }
}
if( strRno == null ) {
   response.sendError( HttpServletResponse.SC_NOT_FOUND );
   return;
}
PreparedStatement sql=con.prepareStatement("select photo from blob_test WHERE
rno = ? );
sql.setInt( 1, rno );
ResultSet rs = sql.executeQuery();

then create any jsp or html page that includes those lines:
<html>
....
<img src="urlToYourServlet?rno=13" >
<img src="urlToYourServlet?rno=14" >
<img src="urlToYourServlet?rno=5" >
<img src="urlToYourServlet?rno=13" >
.....
</html>
0
 
LVL 92

Expert Comment

by:objects
ID: 8099600
thats what I just said :)
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:handsome1234
ID: 8100006
ok,thanks ,
but i didnot want to create more pages for that

can i contol more photos display just in only one page ?
as i recently asked ?
0
 
LVL 92

Accepted Solution

by:
objects earned 1000 total points
ID: 8100090
> can i contol more photos display just in only one page ?

no. a servlet can only return a single image.
0
 
LVL 2

Expert Comment

by:syd108
ID: 8120248
The way i have dealt with this in the past is by just storing the path to the image(on web server) in the database and by simply using it in the src of the img tag.

regards
syd
0
 
LVL 35

Expert Comment

by:girionis
ID: 10041009
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

- Points to objects

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

girionis
EE Cleanup Volunteer
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Summer 2017 Scholarship Winners have been announced!
In today's business world, data is more important than ever for informing marketing campaigns. Accessing and using data, however, may not come naturally to some creative marketing professionals. Here are four tips for adapting to wield data for insi…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question