----------------------------------------------------------------
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!!!
----------------------------------------------------------------

Have you tried thi in the jsrv.properties?

# An environment name with value passed to the JVM
# Syntax: wrapper.env=[name]=[value] (String)
# Default: NONE on Unix Systems
#          SystemDrive and SystemRoot with appropriate values on Win32 systems
wrapper.env=DISPLAY=localhost:0




fractals wrote:

> ----------------------------------------------------------------
> 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!!!
> ----------------------------------------------------------------
>
> Hi everyone,
>
> First of all:
>
> JServ version: 1.1.2
> Apache version: 1.3
> Linux SuSE 7.0, AMD Duron processor 700 Mhz, 256 Mb RAM
> JDK 1.3
>
> I want to (should I say "have to") do graphics on an offscreen port to
> export it in gif format. I tried the following code
>
> public class test
> extends HttpServlet
> {
>     HttpServletRequest req;
>     HttpServletResponse res;
>
>     public static void main ( String [] args )
>     {
>         try
>         {
>             // initialisation du port graphique
>             BufferedImage image = new BufferedImage ( 550, 400,
> BufferedImage.TYPE_INT_RGB );
>
>             Graphics2D g2d = image.createGraphics ();
>
>             g2d.setColor ( Color.red );
>             g2d.fillRect ( 100, 100, 400, 300 );
>
>             DataOutputStream output = new DataOutputStream ( new
> FileOutputStream ( "haha.gif" ) );
>             int [] pixels = new int [550*400];
>             image.getRGB ( 0, 0, 550, 400, pixels, 0, 550 );
>             GIFImage gi = new GIFImage ( pixels, image.getWidth () );
>             GIFOutputStream gos = new GIFOutputStream ( output );
>             gi.write ( gos );
>             gos.flush ();
>             gos.close ();
>         }
>         catch ( Exception e )
>         {
>             System.out.println ( "Error: " + e.getMessage () );
>             e.printStackTrace ();
>         }
>     }
>
>     public void service ( HttpServletRequest req, HttpServletResponse res )
>         throws ServletException
>     {
>         long then = System.currentTimeMillis ();
>         this.req = req;
>         this.res = res;
>         try
>         {
>             // initialisation du port graphique
>             BufferedImage image = new BufferedImage ( 550, 400,
> BufferedImage.TYPE_INT_RGB );
>
>             Graphics2D g2d = image.createGraphics ();
>
>             g2d.setColor ( Color.red );
>             g2d.fillRect ( 100, 100, 400, 300 );
>
>             res.setContentType ( "image/gif" );
>             DataOutputStream output = new DataOutputStream
>  res.getOutputStream () );
>             int [] pixels = new int [550*400];
>             image.getRGB ( 0, 0, 550, 400, pixels, 0, 550 );
>             GIFImage gi = new GIFImage ( pixels, image.getWidth () );
>             GIFOutputStream gos = new GIFOutputStream ( output );
>             gi.write ( gos );
>             gos.flush ();
>             gos.close ();
>         }
>         catch ( Exception e )
>         {
>             System.out.println ( "Error: " + e.getMessage () );
>             e.printStackTrace ();
>         }
>     }
> }
>
> The main method works on linux, but the servlet does not work (it works on
> Wintel though).
>
> This is the error I get (in /var/log/httpd/jserv.log)
>
> [28/12/2000 23:40:45:305 CET] java.lang.InternalError: Can't connect to X11
> window server using ':0.0' as the value of the DISPLAY variable.
>  at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
>  at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:58)
>  at java.lang.Class.forName0(Native Method)
>  at java.lang.Class.forName(Class.java:120)
>  at
> java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment
> .java:58)
>  at java.awt.image.BufferedImage.createGraphics(BufferedImage.java:1011)
>  at com.ubimaps.servlets.test.service(test.java:51)
>  at javax.servlet.http.HttpServlet.service(HttpServlet.java:311)
>  at
> org.apache.jserv.JServConnection.processRequest(JServConnection.java:317)
>  at org.apache.jserv.JServConnection.run(JServConnection.java:188)
>  at java.lang.Thread.run(Thread.java:484)
>
> Can somebody help. (I could always make a server and run it on a console
> from an X session and redirect my servlet to it, but I consider this to be
> an inacceptable hack :-)
>
> thanks in advance,
>
> candide kemmler
>
> NB: I'm new to linux, new to Apache and new to JServ (but not new to
> servlets neither java)
>
> --
> --------------------------------------------------------------
> Please read the FAQ! <http://java.apache.org/faq/>
> To subscribe:        [EMAIL PROTECTED]
> To unsubscribe:      [EMAIL PROTECTED]
> Search Archives:
> <http://www.mail-archive.com/java-apache-users%40list.working-dogs.com/>
> Problems?:           [EMAIL PROTECTED]



--
--------------------------------------------------------------
Please read the FAQ! <http://java.apache.org/faq/>
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Search Archives: 
<http://www.mail-archive.com/java-apache-users%40list.working-dogs.com/>
Problems?:           [EMAIL PROTECTED]

Reply via email to