NeedsHelp
NeedsHelp

Reputation: 437

JSP - How to use an image, sent from a servlet, amongst the HTML a JSP page?

I have this code:

byte[] bytes = IOUtils.toByteArray(is);

            response.setContentType("image/jpeg");

            response.setContentLength(bytes.length);

            response.getOutputStream().write(bytes);

When it runs the page that comes up is just a blank webpage with the image on top. How do I send this image to the JSP to use amongst the HTML?

Upvotes: 0

Views: 345

Answers (1)

Kayaman
Kayaman

Reputation: 73528

Set the src tag to point to the servlet's url as in <img src="/servlet/url/here"></img>.

Upvotes: 2

Related Questions