Originally Posted by TryingToLearn
Its actually quite easy.
In your image/chart servlet generate the image in question.
Set the response content type to "image/jpeg" or what ever your real content type is.
Get the response writer from the HttpServletResponse and write your image to that writer.
If you're using a pure servlet then just let the method exit. Or, if you're using struts or spring MVC then return null.
Here is a decent example from the google search "dynamic images with java servlets":
Creating Images in a Java Servlet
Best of Luck.
There are a couple of gotchas when working with the response writer stream... The biggest one is you must set the content type before anything has been written to the stream. I think there are some other subtle ones as well, but I can't quite remember them right now...