
Originally Posted by
TryingToLearn
Just because I am not sure how I would server up the image directly, could you give a quick explanation on how I would do that?
Sure...
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.
Edit:
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...
Bookmarks