You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Wei Gao <we...@hypergrove.com> on 2002/11/05 22:38:53 UTC
use http-equiv to refresh the page
Hi, this is not a mod_perl question, but rather a question to see if I have to use mod_perl to achive this.
In my perl program executing in Apache web server, I have the following code:
use CGI ;
$query = new CGI ;
$url = http://www.mycite.com ; #The url to refresh.
print $query->header(-status=>'200 Ok', -type=>'text/html');
print "<html><head><meta http-equiv=\"Refresh\" content=\"0;URL=$url\" /></head></html>";
However, when I tried to display it in Internet Explorer, I got an empty page, instead of being redirected to the URL I specified. The same code works fine with ActiveState in IIS. Is this an issue with Apache? How can I make this work? By using Mod_PERL? I am currently using Perl 5.6.1.
Thanks for any comments.
Wei Gao
Re: use http-equiv to refresh the page
Posted by Perrin Harkins <pe...@elem.com>.
Wei Gao wrote:
> I have tried "print
> $query->redirect('http://somewhere.else/in/movie/land') ;" before,
> which works fine as to redirect the user to the web page. However, if
> the user then tries to refresh this page, the CGI script is called
> again without any params, which result in "Internal Server Error".
You lost me. If you redirect the user to http://mycite.com/, and then
the user reloads, he should be reloading http://mycite.com/. I don't
see any reason why that wouldn't work. Are you saying that reload in IE
goes back to the URL that issued the redirect and reloads that? Even if
it does, it should still be submitting the query string or POST data,
although the user may get a pop-up asking if he wants to submit POST
data again.
> Is using <meta> tag a "bad" approach?
Yes. It's something that Netscape added to their browser, which others
may or may not add to their browsers. It's not part of any HTTP spec
and isn't guaranteed to work, even on totally correct web browsers.
- Perrin
Re: use http-equiv to refresh the page
Posted by Wei Gao <we...@hypergrove.com>.
Thanks.
I have tried "print $query->redirect('http://somewhere.else/in/movie/land') ;" before, which works fine as to redirect the user to the web page. However, if the user then tries to refresh this page, the CGI script is called again without any params, which result in "Internal Server Error". So, the goal I want to achieve is that the user can refresh the page I returned without getting an error. It should refresh the web page, not calling my CGI script again.
I also tried "print $query->redirect(-uri=>'http://somewhere.else/in/movie/land', -nph=>1);" moments ago, which generated an "Internal Server Error" in IE window.
Is using <meta> tag a "bad" approach? I thought this is a way to solve my situation here.
Wei
----- Original Message -----
From: Perrin Harkins
To: Wei Gao
Cc: modperl@perl.apache.org
Sent: Tuesday, November 05, 2002 2:50 PM
Subject: Re: use http-equiv to refresh the page
Wei Gao wrote:
> In my perl program executing in Apache web server, I have the
> following code:
>
> use CGI ;
>
> $query = new CGI ;
> $url = http://www.mycite.com ; #The url to refresh.
>
> print $query->header(-status=>'200 Ok', -type=>'text/html');
> print "<html><head><meta http-equiv=\"Refresh\"
> content=\"0;URL=$url\" /></head></html>";
Uh, that's not a redirect; that's an ugly proprietary hack. You should
be using standard HTTP redirects. See
http://search.cpan.org/author/JHI/perl-5.8.0/lib/CGI.pm#GENERATING_A_REDIRECTION_HEADER
for more.
- Perrin
Re: use http-equiv to refresh the page
Posted by Perrin Harkins <pe...@elem.com>.
Wei Gao wrote:
> In my perl program executing in Apache web server, I have the
> following code:
>
> use CGI ;
>
> $query = new CGI ;
> $url = http://www.mycite.com ; #The url to refresh.
>
> print $query->header(-status=>'200 Ok', -type=>'text/html');
> print "<html><head><meta http-equiv=\"Refresh\"
> content=\"0;URL=$url\" /></head></html>";
Uh, that's not a redirect; that's an ugly proprietary hack. You should
be using standard HTTP redirects. See
http://search.cpan.org/author/JHI/perl-5.8.0/lib/CGI.pm#GENERATING_A_REDIRECTION_HEADER
for more.
- Perrin