Solved

Status Code 302

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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Introduction:   Welcome to my first article ever. To begin with, the reason I write this article.  I participated in a question on Experts Exchange about the start command in Windows and there were some discussion about the usage. The discussio…
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.
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
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 …

728 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