----------------------------------------------------------------
BEFORE YOU POST, search the faq at <http://java.apache.org/faq/>
WHEN YOU POST, include all relevant version numbers, log files,
and configuration files. Don't make us guess your problem!!!
----------------------------------------------------------------
Thank you Ulrich, but I think that Jserv will serve my purposes rather well.
I am creating a web which will show information from a database, storing
financial data. The data will be frequently updated, and thus also the
webpage. The reason why I need to output an image is that I need to have
dynamic graphs on the page. I am aware of what you said about servlets not
having a desktop like applets where images are displayed, but I know that
there is another way.
In a java servlet tutorial (webreview.com/97/11/14/webdev) they do it like
this:
Here they create an image:
Frame sourceFrame = new Frame();
sourceFrame.addNotify();
Image im = sourceFrame.createImage(100,100);
Graphics g = im.getGraphics();
g.drawString("Hello",50,50);
Here they ouput it:
resp.setContentType("image/gif");
ServletOutputStream out = resp.getOutputStream();
Image im = makeOurImage(); // custom method to generate an image
try
GIFEncoder g = new GIFEncoder(im);
g.Write(out);
} catch(java.awt.AWTException e)
// some error handling code
}
out.flush();
(GIFEncoder is a freeware application).
However, this does not work when I try it and produces similar errors to
what I described earlier!
Ásta
----- Original Message -----
From: Voigt, Ulrich <[EMAIL PROTECTED]>
To: 'Java Apache Users' <[EMAIL PROTECTED]>
Sent: Monday, January 24, 2000 5:58 PM
Subject: RE: Problems with images in servlets (classes not found)
> ----------------------------------------------------------------
> BEFORE YOU POST, search the faq at <http://java.apache.org/faq/>
> WHEN YOU POST, include all relevant version numbers, log files,
> and configuration files. Don't make us guess your problem!!!
> ----------------------------------------------------------------
>
> Hello,
>
> I think Apache and JServ are not the right tools for you. You want to
create
> an application but this has nothing to do with servlets!
>
> You must decide if you want to create an application with the standard awt
> and a graphical user interface or if you want to use servlets to create
> dynamic HTML pages. You can't use awt classes in servlets because you
don't
> have a desktop where your application is shown. (This is the error with
you
> X11 window).
>
> I recommend to read the Java-Tutorial from Sun. There are some examples
that
> explain how to use servlets .
> (http://java.sun.com/docs/books/tutorial/index.html)
>
> Ulrich
> > -----Original Message-----
> > From: Ásta Herdís Hall [SMTP:[EMAIL PROTECTED]]
> > Sent: Monday, January 24, 2000 6:44 PM
> > To: [EMAIL PROTECTED]
> > Subject: Problems with images in servlets (classes not found)
> >
> > Hello,
> >
> > I am new to servlets and Apache JServ. I am running ApacheJServ-1.1b3
and
> > Apache_1.3.9 on Redhat Linux 6.1. My version of jdk is Blackdown
jdk1.2.2
> > release 3. I have got the configuration working fine for plain
servlets,
> > such as the Hello servlet, and also it works fine for servlets which
> > connect to a mysql database.
> >
> > However, my problems start when I am going to output an image to the
> > webpage. The following program which doesn't do anything else than
> > creating an image, but it still fails.
> >
> > import java.io.*;
> > import java.sql.*;
> > import javax.servlet.*;
> > import javax.servlet.http.*;
> >
> > import java.awt.*;
> > import sun.awt.*;
> > import sun.awt.motif.*;
> > import sun.awt.motif.MToolkit;
> >
> > public class chartTst extends HttpServlet
> > {
> > public void init(ServletConfig conf) throws ServletException
> > {
> > super.init(conf);
> > Frame sourceFrame = new Frame();
> > sourceFrame.addNotify();
> > Image im = sourceFrame.createImage(100,100);
> > Graphics g = im.getGraphics();
> > g.drawString("Hello",50,50);
> > }
> > }
> >
> > The error it generates in the jserv.log is as follows
> > [24/01/2000 17:25:27:458 GMT+00:00] <servletException>
> > java.lang.NoClassDefFoundError: sun/awt/motif/MToolkit
> > at java.lang.Class.forName0(Native Method)
> > at java.lang.Class.forName(Class.java, Compiled Code)
> > at java.awt.Toolkit$2.run(Toolkit.java, Compiled Code)
> > at java.security.AccessController.doPrivileged(Native Method)
> > at java.awt.Toolkit.getDefaultToolkit(Toolkit.java, Compiled
Code)
> > at java.awt.Window.getToolkit(Window.java, Compiled Code)
> > at java.awt.Frame.addNotify(Frame.java, Compiled Code)
> > at chartTst.init(chartTst.java, Compiled Code)
> > at
> > org.apache.jserv.JServServletManager.load_init(JServServletManager.java,
> > Compiled Code)
> > at
> >
org.apache.jserv.JServServletManager.loadServlet(JServServletManager.java,
> > Compiled Code)
> > at
> > org.apache.jserv.JServConnection.processRequest(JServConnection.java,
> > Compiled Code)
> > at org.apache.jserv.JServConnection.run(JServConnection.java,
> > Compiled Code)
> > at java.lang.Thread.run(Thread.java, Compiled Code)
> >
> > The class sun/awt/motif/MToolkit is in the rt.jar (java runtime) and I
> > have put it in the wrapper.classpath in jserv.properties, but nothing
> > works.
> >
> > I have also had the following error
> > <servletException> java.lang.InternalError: Can't connect to X11 window
> > server using ':0.0' as the value of the DISPLAY variable.
> >
> > Does anyone know what the value of the DISPLAY variable should be?!
> >
> > I really hope that someone can help me with this problem. I have read
the
> > faq through several times without any luck and I have also scanned the
> > mailing list with the same result.
> >
> > Thank you,
> > Ásta
>
>
> --
> --------------------------------------------------------------
> Please read the FAQ! <http://java.apache.org/faq/>
> To subscribe: [EMAIL PROTECTED]
> To unsubscribe: [EMAIL PROTECTED]
> Archives and Other: <http://java.apache.org/main/mail.html>
> Problems?: [EMAIL PROTECTED]
>
--
--------------------------------------------------------------
Please read the FAQ! <http://java.apache.org/faq/>
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Archives and Other: <http://java.apache.org/main/mail.html>
Problems?: [EMAIL PROTECTED]