dcsimg
need help with applet communicating with cgi/perl
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Kimberly_Hendershot
Posted On:   Monday, August 19, 2002 12:45 PM

Hi all.



I have an existing cgi script written in perl. I have to modify it so that it can take information from my applet and use it. I think I can send the string to the cgi via a post method, but I do not know how to code the cgi to use the string. I don't know much about perl and I'm having trouble finding perl/applet communication examples.


Any suggestions would be great. Thanks :)

Re: need help with applet communicating with cgi/perl

Posted By:   Anonymous  
Posted On:   Tuesday, August 20, 2002 03:48 AM

I havenĀ“t tried it. But my Perl IDE generated the following code for handling the HTTP-Request:

The HTML








The Perl code

&GetFormInput
# The intermediate variables below make your script more readable
# but somewhat less efficient since they are not really necessary.
# If you do not want to use these variables, clear the
# Intermediate Variables checkbox in the Tools | Options dialog box, CGI Wizard tab.

$Name = $field{'Name'} ;
$Prename = $field{'Prename'} ;

sub GetFormInput {

(*fval) = @_ if @_ ;

local ($buf);
if ($ENV{'REQUEST_METHOD'} eq 'POST') {
read(STDIN,$buf,$ENV{'CONTENT_LENGTH'});
} else {
$buf=$ENV{'QUERY_STRING'};
}
if ($buf eq "") {
return 0 ;
} else {
@fval=split(/&/,$buf);
foreach $i (0 .. $#fval){
($name,$val)=split (/=/,$fval[$i],2);
$val=~tr/+/ /;
$val=~ s/%(..)/pack("c",hex($1))/ge;
$name=~tr/+/ /;
$name=~ s/%(..)/pack("c",hex($1))/ge;

if (!defined($field{$name})) {
$field{$name}=$val;
} else {
$field{$name} .= ",$val";

#if you want multi-selects to goto into an array change to:
#$field{$name} .= "\0$val";
}
}
}
return 1;
}

About | Sitemap | Contact