This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Applets and the fly likes Executing cgi script from applet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Executing cgi script from applet" Watch "Executing cgi script from applet" New topic
Author

Executing cgi script from applet

Richard Walter
Greenhorn

Joined: May 26, 2001
Posts: 22
Hi all,
Im having trouble executing my cgi script from an applet I've written. Hopefully someone can tell me what Im doing wrong.
My main goal is to write some data from an applet to a file using a simple cgi script. For example if you type this URL into your browser:
http://www.flyaustralia.net/cgi-bin/test1.cgi?test
it will write 'test' to a file called 'wd.txt' at:
http://www.flyaustralia.net/wd.txt
The problem is i cant seem to execute this script from my applet, or at least it doesn't seem to do anything. Here's the main bit of code:

public void CGIPost(String data) throws Exception {
URLurl = new URL("http://www.flyaustralia.net/cgi-bin/test1.cgi?5555");
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setRequestMethod("GET");
connection.setDoInput(true);
connection.connect();
System.out.println("opoening connection to test1.cgi and sending 5555: URL is " + url);
}
The applet is loaded onto the server and no exceptions are thrown when running the applet. However, nothing is written to wd.txt.
Any help would be much appreciated.
Rich
P.S.you can test the applet here:
http://www.flyaustralia.net/Test1.htm
Here is the cgi script if it is a help:
#!/usr/bin/perl
use CGI::Carp qw(fatalsToBrowser);
$data=$ENV{'QUERY_STRING'};
open(OUT,">/home/flyaustralia/www/wd.txt");
print OUT $data;
close(OUT);
print "Content-type:text/html\n\n";
print <<EndHTML
<html><head><title>Hello!</title></head>
<body>
<h2>Hello!</h2>
The string sent was $data<p>
</body>
</html>
EndHTML

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Executing cgi script from applet
 
Similar Threads
Ajax.Updater not displaying
Executing cgi script from applet
Japan Times: Pentagon said to eye nuclear attack against terrorists
Executing cgi script from applet
How far can you take HttpURLConnection