Also, storing the byte array in the session strikes me as a Bad Idea, as any big images (or large number of users) will crash the container with an out of memory error..
Why not get the array straight from the db, and push it straight out to the user?
As I said though, it all depends on what you are saving in the database...
If you have just read the gif byte by byte, and written that into the database, what you are doing should work...maybe you just need:
<%
byte[] bytes = (byte[]) session.getAttribute("imag
OutputStream stream = response.getOutputStream()
stream.write(bytes);
stream.flush() ;
%>
Tim
Main Topics
Browse All Topics





by: TimYatesPosted on 2005-08-30 at 04:10:35ID: 14783154
What is stored in the database?
e"); ;
The pixel values?
What sort of image? Indexed? Have you stored the palette?
What happens if you go straight to jsp/logo.jsp (ie, point the browser at the image generating jsp)
If it is actual pixel values stored in the database, then you should be able to do:
<%
byte[] bytes = (byte[]) session.getAttribute("imag
InputStream is = new ByteInputStream( bytes ) ;
Image image = ImageIO.read( is ) ;
OutputStream stream = response.getOutputStream()
ImageIO.write( image, "JPG", stream ) ;
%>
And set the content type to "image/jpg"
maybe... I haven't tried that out though... :-/
Tim