Solved

Status Code 302

Posted on 1997-06-19
5
161 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
  • 3
  • 2
5 Comments
 
LVL 2

Accepted Solution

by:
mkornell earned 50 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

In this tutorial I will aim to show you how simple is making a small application in WhizBase, how to add, remove and update data in the DB. I will make a small address book application where you can add, browse, update and remove addresses. I wi…
Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

803 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