views:

24

answers:

1

I decided to store uploaded to servlet pictures in DB. But how to show them in browser (in particular div with css image-background style) without page reload?

In details: I have an full-AJAX web client that works with java servlet.

Thanks.

+2  A: 
  1. Create a servlet that accepts a name / id uniquely identifying the picture as a GET parameter
  2. Let the servlet load the picture from DB (as byte array or better - as stream)
  3. Stream the picture using response.getOutputStream()
  4. Don't forget to set the content-type to image/png or image/jpeg
  5. Refer to the image in the css with url: imageServlet?id=13214
Bozho