What's your servlet environment? Whenever you get an internal server
error, you should consult the logs. My guess is that in this case, you've
got a Unix servlet engine running without an X server attached. You'll
need to run an X server (virtual or not), or change AWT implementation,
in order to use any graphics.
--
Jon Skeet - sk...@pobox.com
http://www.pobox.com/~skeet/
yes, you are right. that seems to be the problem. i am using a LINUX
machine, but a x-server is installed, since the graphical environment can be
started.
the question now is how to configure the x-server (or java), so that it
works. any idea?
lg
tom
Probably just starting the X server is enough, and set the DISPLAY
environment variable in the shell that you run the servlet engine under.
(That's probably the tricky bit.)
that problem seems fixed.
my jserv-log contains this message now:
java.lang.NoClassDefFoundError: sun/awt/X11GraphicsEnvironment
at
org.apache.jserv.JServConnection.processRequest(JServConnection.java:323)
at org.apache.jserv.JServConnection.run(JServConnection.java:188)
at java.lang.Thread.run(Thread.java:475)
what am i missing?
tom.
Sounds like you're missing part of the JRE - namely the awt part. See if
you can run a normal GUI app from X using the same jre.
--
Jon Skeet
sk...@pobox.com - http://www.pobox.com/~skeet
import Acme.JPM.Encoders.*;
:
Frame container = new Frame();
try{
container.addNotify();
container.add(button);
Image img = null;
img = container.createImage(gifWidth,gifHeight+20);
Graphics g = img.getGraphics();
: Draw your image
ServletOutputStream out = response.getOutputStream();
GifEncoder gif = new GifEncoder(img,out);
gif.encode();
out.flush();
}catch(Exception ex){
ex.printStackTrace();
}finally{
container.dispose();
}
Notice my use of new GifEncoder(img,out);
I grabbed this gif encoder curtesy of http://www.acme.com/. There's a lot
of free code samples and class libraries at this site. Mostly written by
one guy I think.. Very prolific and capable person.
Cheers and good luck.
David Balme
Thomas Kern wrote:
> Hi,
> I try to generate a HTML-page in my servlet containing a GIF graphics.
> However, if I use following lines in my doGet()-method I get a "Internal
> Server Error" message in my browser.
> BufferedImage img = new BufferedImage(x, y, BufferedImage.TYPE_INT_RGB);
> Graphics g = img.getGraphics(); // this causes the error
> I'd need a Graphics object to paint my picture on, how do i do that in a
> servlet? In my application everything worked fine ...
> Thanx
> tom.