Solved

Status Code 302

Posted on 1997-06-19
5
159 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to find "path" in Windows 10 12 56
How to Skip in FOR command if a Directory does not exist. 6 68
Need to learn promise API 2 43
Need to Modify a Script I found 5 92
Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
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.
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
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…

930 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

11 Experts available now in Live!

Get 1:1 Help Now