petrow
asked on
Writing CGI in Java
I decided to try to write a Java CGI program as an experiment to see how well it ports from UNIX to Win9*
(yes, I know it's slow as a dog and wouldn't work well
in practice...)
The Java source code is:
import java.lang.*;
public class JavaHello {
public static void main(String argv[]) {
char space = ' ', newline = '\n', plus = '+';
String request = System.getProperty("JavaHe llo.reques t");
String clength = System.getProperty("JavaHe llo.clengt h");
String query_s = System.getProperty("JavaHe llo.query" );
StringBuffer query = new StringBuffer(query_s);
for (int i=0;i<query.length();i++) {
if (query.charAt(i) == plus) {
query.setCharAt(i,space);;
}
}
query_s = query.toString();
System.out.println("Conten t-type: text/plain");
System.out.println();
System.out.println("Hello World!");
System.out.println("Reques t type is " + request);
System.out.println("Query String is " + query_s);
System.out.println("Conten t-Legnth: " + clength);
System.out.flush();
}
}
This is called by a shell script javahello.cgi in UNIX:
#!/bin/sh
JAVA_HOME=/usr/local/jdk1. 1.3
PATH=/usr/local/jdk1.1.3/b in:/usr/lo cal/jdk1.1 .3/bin:/us r/local/bi n:/bin:/us r/bin:.:/u sr/X11R6/b in:/usr/bi n/mh:/usr/ X11R6/bin: /usr/bin/m h
cd /home/httpd/html/JAVAtest/ joetest
-DJavaHello.query=$QUERY_S TRING -DJavaHello.clength=$CONTE NT_LENGTH JavaHello
exec java -DJavaHello.request=$REQUE ST_METHOD -DJavaHello.query=$QUERY_S TRING -DJavaHello.clength=$CONTE NT_LENGTH JavaHello
#java JavaHello
My question is, how would I get this to run on a Windows
server?
(yes, I know it's slow as a dog and wouldn't work well
in practice...)
The Java source code is:
import java.lang.*;
public class JavaHello {
public static void main(String argv[]) {
char space = ' ', newline = '\n', plus = '+';
String request = System.getProperty("JavaHe
String clength = System.getProperty("JavaHe
String query_s = System.getProperty("JavaHe
StringBuffer query = new StringBuffer(query_s);
for (int i=0;i<query.length();i++) {
if (query.charAt(i) == plus) {
query.setCharAt(i,space);;
}
}
query_s = query.toString();
System.out.println("Conten
System.out.println();
System.out.println("Hello World!");
System.out.println("Reques
System.out.println("Query String is " + query_s);
System.out.println("Conten
System.out.flush();
}
}
This is called by a shell script javahello.cgi in UNIX:
#!/bin/sh
JAVA_HOME=/usr/local/jdk1.
PATH=/usr/local/jdk1.1.3/b
cd /home/httpd/html/JAVAtest/
-DJavaHello.query=$QUERY_S
exec java -DJavaHello.request=$REQUE
#java JavaHello
My question is, how would I get this to run on a Windows
server?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Somehow my answer got a bit jumbled -- your batch file will work better if you don't include my name in it. Instead, include the stuff below it.