开发者

How to show images in div that stored in db

I decided to store uploaded to servlet pictures in DB. But how to show them in browser (in particular div with css image-backgr开发者_高级运维ound style) without page reload?

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

Thanks.


  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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜