Link to home
Start Free TrialLog in
Avatar of sushrut
sushrut

asked on

implement JSP response.sendRedirect() in perl

How can I implment JSP response.sendRedirect() in perl cgi in Netscape fastrack server in perl 5.005_03 built for aix.


What is the exact process/data (At low level) that goes on between two application servers. ?


I want to redirect a request from AIX-Netscape Fastrack server to NT-ASP  page.
Avatar of clockwatcher
clockwatcher

I think that sendRedirect() simply adds a Location field to the HTTP Response's header.  

The following would redirect the browser to yahoo.


example.pl
------------

#!/usr/bin/perl

print "Location: http://www.yahoo.com\n\n";
ASKER CERTIFIED SOLUTION
Avatar of rj2
rj2

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
so does code above
sushrut,

Try this:

---------------- redirect.pl ----------------------
#!/usr/bin/perl

use CGI;
my $q = new CGI;
my $url = "http://www.somedefaultsite.com";
$url = $q->param('url') if(defined $q->param('url'));

print $q->redirect($url);

---------------------------------------------------

You can use the above script for redirecting to any url/webpage by passing the target as parameter to the script. If u call the script as :
http://ww.somesite.com/cgi-bin/redirect.pl?url=http://www.abc.com

the above will redirect to www.abc.com ,
if no url is specified it will redirect to the default mentioned in the script (i.e www.somedefaultsite.com)

hope the above helps.

Aman
:-)