File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes How to display an image file to jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to display an image file to jsp" Watch "How to display an image file to jsp" New topic

How to display an image file to jsp

John McDonald
Ranch Hand

Joined: Jul 01, 2003
Posts: 112
Hi there,
In the server code, if I have an image file on the memory, how do I write it in to a jsp file to display? I don't want to disposite to a physical location and then use image tag <img src=".../picture.jpg">. Thanks.

John Giang
[ December 19, 2005: Message edited by: Ben Souther ]
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63544

The src of the image tag can reference a servlet that can serve up the image data. Be sure to set the response headers correctly.

[Asking smart questions] [About Bear] [Books by Bear]
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

If you'd like an example, I have one on my site.
Look for SimpleStream.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
I agree. Here's the link:
subject: How to display an image file to jsp
It's not a secret anymore!