How to embed images from a database into web pages

One possible way to store images in a database is a bit stream. This works as a storage mechanism, but I cannot figure out how to embed this data in a web page as an image, as soon as I retrieve it to fulfill a client request.

I work with servlets in Java. Can someone give me a guide?

+3
source share
2 answers

You might want to write a servlet that reads the BLOB from the database and copies directly to HttpServletRequest.getOutputStream(), remembering to set the content type to the appropriate format (for example, an image / png).

, (/image/foo), (/image? id = foo). <img>.

, , Java, JSP .

+1

, HTML, - , , ​​, .:)

html, , html jarred [clientid].jar . . ( ) . jar , ( unix FS) - ( ) FileXfer ObjectOutputStream. tmp tmpdir deleteOnExit.

, html, , html, -. (jpeg, png ..) . - deleteOnExit, . html , , , . - , "logo.png", 15 , HTML ..

, :

  • , , 3 (jar zip-compression)

  • () html,

  • ( - , )

  • html img, $cwd

  • [clientid].jar , , .

TIA , - M.S.

0

Source: https://habr.com/ru/post/1786537/


All Articles