Page 1 of 1

CGI

Posted: Mon Mar 27, 2006 2:22 pm
by shiznatix
ok i have a uncompiled java program that I need to run as a website thingy. Do I need to compile it first or can I keep it uncompiled and compile it on the fly, basically which one is easier, speed does not matter.

Next question!

the .cgi file...how? Here is what I have kinda half arsed put together but I dont know what it does

Code: Select all

#!/bin/sh
cd /tmp
  /usr/local/java/j2sdk1.4.2_02/bin/java -cp /home/shiznatix/cgi/
    proov $QUERY_STRING
where /home/shiznatix/cgi/ is the location of the .java file. The /usr/local... is supposed to be the location of my java compiler? I know that the location i have there is wrong but I dont know where it is located because I always just use the javac command. also, what is $QUERY_STRING?? Makes no sence to me...

Re: CGI

Posted: Mon Mar 27, 2006 2:52 pm
by timvw
shiznatix wrote:ok i have a uncompiled java program that I need to run as a website thingy. Do I need to compile it first or can I keep it uncompiled and compile it on the fly, basically which one is easier, speed does not matter.
If you want to run a java program, you have to compile it first to .class files.
Then you can launch it with a java runtime..

Spawning a php or perl process was slow, and i'm sure that spawning a java process will be even slower... (Why not use a java webcontainer? I've found resin very easy to get up and running.
shiznatix wrote: the .cgi file...how? Here is what I have kinda half arsed put together but I dont know what it does

Code: Select all

#!/bin/sh
cd /tmp
  /usr/local/java/j2sdk1.4.2_02/bin/java -cp /home/shiznatix/cgi/
    proov $QUERY_STRING
Well, you need a script that invokes a java runtime with the wanted class file.

#!/usr/local/java/bin/java -cp /wherever/your/classpath/is program_file_name_without_class_at_end
shiznatix wrote: $QUERY_STRING??
Well, CGI is simply a definition how your webserver and application communicate. Your server will pass data via environment variables.. Eg: QUERY_STRING.

Anyway, you might want to read: http://www.javaworld.com/javaworld/jw-0 ... ripts.html