Please browse the categories below to previous answers to questions like yours. If you do not find the answer for your particular situation, ask for help on the appropriate mailing list.
(Answer) (Category) Java Apache Project : (Category) Apache JServ 1.0 : (Category) Programming and Misc. Tidbits :
How do I create an image with a servlet, for example, a graph out of a list of values?
Servlets allow you to specify the content type of the response. This ability let you generate dynamic images simply mapping the <img> tag with the proper servlet URL. To do this, you need to generate an off-screen image object and send it encoded in your favorite image format. Free GIF image encoders are not available due to patent restrictions, while JDK 1.2 contains a JPG image encoder (and few others like PNG may be added in the future).

To create an off-screen image you could follow these guidelines:

Frame f = new Frame();

f.addNotify() // <-- this creates a "frame peer", which makes it all work

Image img = f.createImage();
doMyPaintImage(img.getGraphics());

(etc.)

Note that it apparently needs to be a Frame since Canvas doesn't seem to work. It probably just calls for the toplevel window component to do the job. (Thanks to Bjorn Sandberg).

If you are running on a Unix box, then to create a Frame the Java process needs access to a X server (and the DISPLAY environment variable set). If you do not want the overhead of running an X server, then you can use Xvfb which creates a virtual X server.
[Append to This Answer]
Previous: (Answer) I have a directory within my servlets directory and things break when I try to use http://www.server.com/servlets/test/TestServlet, but when I put TestServlet directly in the servlets directory and remove the "test" from the URL, things work just fine. Is this a bug?
Next: (Answer) When I call HttpUtils.parsePostData() all the POST data is eaten by Apache Jserv. Is this a bug?
This document is: http://java.apache.org/faq/?file=204
[Search] [Appearance] [Show Expert Edit Commands]
This is a Faq-O-Matic 2.709.
Please browse the categories below to previous answers to questions like yours. If you do not find the answer for your particular situation, ask for help on the appropriate mailing list.