?
Solved

Status Code 302

Posted on 1997-06-19
5
Medium Priority
?
167 Views
Last Modified: 2013-12-25
I have two CGI scripts (perl) which are running around behind the scenes calling each other with perl's $query->redirect().  When processing is done, the final redirect to a third file (sh script) produces a Status 302. THe script is there, the URL is correct.  Why can't the server find it?  I'm suspecting it has somehow become confused with all the redirects.  Could it be a problem with
the perl routine?  I will attempt it with straight html. In the meantime any help appreciated!
0
Comment
Question by:wspoulin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 2

Accepted Solution

by:
mkornell earned 200 total points
ID: 1828398
A 302 status does not mean that the server couldn't find the script.  It is a message to the browser that means the requested resource has "Moved Temporarily".  The CGI.pm module explicitly sets this status in the redirect method you are calling, and there doesn't seem to be a way to get around it.  Not that you'd want to, anyways.

A 302 status isn't that big of a deal, but it is up to the browser to interpret it properly and issue another request for the redirected-to URL.  Perhaps this is what is causing your problem; what browser and version are you using?

Another way to solve this would be to use the a META tag in the HTML HEAD section, like this:


<HTML><HEAD>
<META HTTP-EQUIV="Refresh" CONTENT=0;URL=http://my.new.url">
</HEAD>
</HTML>

Again, though, the browser has to cooperate.

HTH,
--mark;

0
 

Author Comment

by:wspoulin
ID: 1828399
Mark,
I'm using Netscape 3.0 (Unix and NT).  Does this mean that redirection will not work for me?  It seems odd. The funny part
is that it works on some scripts but not on others. Same permissions, same owners, same redirect call. I just don't
get it!  I will compare a script that works with one that doesnt again.  Any additional thoughts appreciated.

Thanks,Wendy
0
 
LVL 2

Expert Comment

by:mkornell
ID: 1828400
Netscape 3 certainly supports the <META REFRESH> tag, as does IE 3+.  Don't know about NS2, IE2.

In your Perl code, take care where you place the ->redirect() statement.  For it to work properly, you must not generate the normal header.  (According to the docs, anyways)
use CGI;
$cgi = new CGI;
print $cgi->redirect ("http://...");
#print $cgi->header;    # don't do this...
#print $cgi->start_html;
#print $cgi->end_html;

You could also skip using the CGI module for output and set the "Location" HTTP header directly:

use CGI;
$cgi = new CGI;  #get the input data (form or querystring)print STDOUT "Location: http://...\n\n";
#note, no CGI output statements.

HTH,
--mark;
0
 
LVL 2

Expert Comment

by:mkornell
ID: 1828401
Oops, need a newline in the last bit:

use CGI;
$cgi = new CGI; #get the input data (form or querystring)
print STDOUT "Location: http://...\n\n";
#note, no CGI output statements.

--mark;

0
 

Author Comment

by:wspoulin
ID: 1828402
Mark,
 Thankyou!  I had an erroneous print->header at the top of the code.  Works like a charm now!

THanks for the help.
Wendy
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It is becoming increasingly popular to have a front-page slider on a web site. Nearly every TV website,  magazine or online news has one on their site, and even some e-commerce sites have one. Today you can use sliders with Joomla, WordPress or …
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question