The standard approach is to have the src tag of the image point at a
Servlet which is part of the webapp.
eg
<img src="/myWebApp/imageServlet?imageid=42"/>
That servlet is then responsible for loading the image, and sending it out via the ServletOutputStream.