tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nikola Milutinovic" <>
Date Fri, 25 Jan 2002 07:31:44 GMT
> > but this means that  i must create and send a second query to a database
> > within in this servlet ,
> > rather then this
> > may be i can share my jsp page`s resultset to servlet,
> > do you have any idea to achive this,
> Even if you used a servlet, you cannot mix text output (the HTML of your
> page) and the binary image data in the same response.  You would need to
> create an <img> link that points at a servlet to return the binary image
> data (which the browser will submit as a second request, in the usual
> way).
> If you don't want to do two database accesses, you can always save the
> image data in the user's session so that the second request sees it there
> already.

Why would we need to generate everything in one servlet? Have JSP page with a HTML tag:

<img src="images/getImage.jsp?id=<%= imageID %>">

and let getImage.jsp handle image retrieval. And if the first page needs to get some data
from DB, yes, it will require two DB accesses.

Whether or not having two DB accesses is "expencive" depends on the "price" of one lookup
via "id" (which should be a primary key) and size of the image.

View raw message