File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General 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
JavaRanch » Java Forums » Java » Java in General
Bookmark "Executing cgi script from applet" Watch "Executing cgi script from applet" New topic

Executing cgi script from applet

Richard Walter

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:
it will write 'test' to a file called 'wd.txt' at:
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("");
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
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 can test the applet here:
Here is the cgi script if it is a help:
use CGI::Carp qw(fatalsToBrowser);
print OUT $data;
print "Content-type:text/html\n\n";
print <<EndHTML>
The string sent was $data


Tracey Currier
Ranch Hand

Joined: Feb 06, 2001
Posts: 50
Hello, I would like to run perl from a remote server, do you know of any that will do this? Or how can I run perl from my browser without having perl installed on my computer? Here is a link I found that may or may not help you with the applet question.
interesting topic

MS,MS,SCJP,SCBCD Seize the day!
Tracey Currier
Ranch Hand

Joined: Feb 06, 2001
Posts: 50
I found the Sambar Server, I am trying it out now. Have you used it?
I agree. Here's the link:
subject: Executing cgi script from applet
It's not a secret anymore!