开发者

How to display images using HTML created by servlets on Jetty web server?

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!


It should point to a valid URL. E.g. absolute <img src="http://example.com/images/foo.jpg"> 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).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜