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

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
handsome1234Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

objectsCommented:
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
kennethxuCommented:
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
objectsCommented:
thats what I just said :)
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

handsome1234Author Commented:
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
objectsCommented:
> can i contol more photos display just in only one page ?

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
syd108Commented:
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
girionisCommented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JSP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.