Solved

Status Code 302

Posted on 1997-06-19
5
158 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

771 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now