views:

28

answers:

1

Hi,

I am trying to display images using an HTML page created by a servlet.

I am using Jetty 6.18 as the web server.

The problem is I'm not sure where to store the image files and how to register them (if needed), since the HTML returned to the client is generated by a servlet.

Let's say I want to write a tag <img src="what_to_write_here?!"> in the HTML. Where should it reference?

Thanks!

A: 

It should point to a valid URL. E.g. absolute <img src="http://example.com/images/foo.jpg"&gt; or relative <img src="images/foo.jpg">. You can just map a local disk file system folder on the given URL, or register a servlet to listen on that URL which in turn gets the image as InputStream from disk and writes it to OutputStream of the response (you can find here a basic example).

BalusC
Thanks! The relative URL worked. I don't know why I got a bit confused by all that.
shwartz
You're welcome.
BalusC