Loading ...
Sorry, an error occurred while loading the content.
 

Re: Redirection

Expand Messages
  • scott.list
    Slow? Thats an understatement. I access the messages from their interface and it s been down completely all day (groups.yahoo.com). Thanks for the suggestion
    Message 1 of 6 , Mar 4, 2002
      Slow? Thats an understatement. I access the messages from their interface and it's been down completely all day (groups.yahoo.com).

      Thanks for the suggestion but it does not work either. It also says ". If you use redirection like this, you should not print out a header as well."

      In this app, the page (and the header of course) is already there. There's the issue, - can't redirect automatically after the page prints "Processing complete".

      Thanks,
      Scott

      ----- Original Message -----
      From: Kyle Hamar
      To: scott.list@...
      Sent: Monday, March 04, 2002 8:34 PM
      Subject: Redirection


      The list is slow tonight. (Sending via direct mail)


      Date: Mon, 04 Mar 2002 18:08:44 -0600
      To: perl-beginner@yahoogroups.com
      From: Kyle Hamar <khamar@...>
      Subject: RE: [PBML] [#2] cgi progressive displaying script ?

      direct from http://www.perldoc.com/perl5.6.1/lib/CGI.html#GENERATING-A-REDIRECTION-HEADER

      GENERATING A REDIRECTION HEADER

      print $query->redirect('http://somewhere.else/in/movie/land');

      Sometimes you don't want to produce a document yourself, but simply redirect the browser elsewhere, perhaps choosing a URL based on the time of day or the identity of the user.
      The redirect() function redirects the browser to a different URL. If you use redirection like this, you should not print out a header as well.
      One hint I can offer is that relative links may not work correctly when you generate a redirection to another document on your site. This is due to a well-intentioned optimization that some servers use. The solution to this is to use the full URL (including the http: part) of the document you are redirecting to.
      You can also use named arguments:
      print $query->redirect(-uri=>'http://somewhere.else/in/movie/land',
      -nph=>1);

      At 11:13 PM 3/4/2002 +0800, you wrote:

      I thought redirects didn't work if you have already printed a header?


      rgds

      Frank

      -----Original Message-----
      From: msws_1 [mailto:scott.list@...]
      Sent: Monday, 4 March 2002 11:04 PM
      To: perl-beginner@yahoogroups.com
      Subject: Re: [PBML] [#2] cgi progressive displaying script ?


      > Try this and let me know if it works! ;-)

      OK, here's the changes and output. Still no redirect happening:
      --------------------------------------
      #!/usr/bin/perl
      use CGI;
      $|=1; # Turn on autoflush
      print "Content-type: text/html\n\n";
      print "<html><body>";
      print "Please wait, processing.";

      # file "stop" exists for this test...
      while (!-e "stop") {
      sleep 2;
      print " .";
      }

      print "<BR><BR>Done, processing......\n\n\n";
      print "</body></html><BR><BR>\n\n";

      # Create a new instance of CGI
      my $query = new CGI;

      # Get the URL to which the user should be directed
      my $target = "http://www.yahoo.com/";

      # Now redirect to the target
      print $query->redirect($target);

      exit;

      ----------------------------
      The result web page (source):
      ----------------------------
      Please wait, processing.

      Done, processing......
      <BR><BR>

      Status: 302 Moved
      Location: http://www.yahoo.com/
      ----------------------------

      Thanks again for the help.
      Scott









      [Non-text portions of this message have been removed]
    • scott.list
      Kyle: Below worked like a charm. Web page prints with continuing .. until I create the file called stop . Then the script tacks on your Java. I used:
      Message 2 of 6 , Mar 5, 2002
        Kyle:

        Below worked like a charm. Web page prints with continuing ".." until
        I create the file called "stop". Then the script tacks on your Java.
        I used:

        print << "END"
        <script language="javascript" type="text/javascript">
        <!--
        window.setTimeout('window.location="http://www.yahoo.com/"',500);
        // -->
        </script>
        END

        Then the page redirects all by itself. Beautiful. Thanks very much
        for the help!

        Scott


        > ----- Original Message -----
        > From: "Kyle Hamar" <khamar@...>
        > To: "scott.list" <scott.list@...>
        > Sent: Monday, March 04, 2002 9:06 PM
        > Subject: Re: Redirection
        >
        >
        > > This should work then,
        > >
        > > This JavaScript example opens the new site in the same browser
        window
        > after displaying the current page in the window for 2 seconds (2000
        ms):
        > > <script language="javascript" type="text/javascript">
        > > <!--
        > >
        window.setTimeout('window.location="http://www.pa.msu.edu/services/";
        > ',2000);
        > > // -->
        > > </script>
        > >
        > > (Note that this does exactly what the HTML META tag above does,
        but as the
        > META tag method does not depend on the browser's having JavaScript
        available
        > and active, in most cases the META tag method would be preferable).
        > > The next JavaScript example opens the new site in a new* browser
        window:
        > > <script language="javascript" type="text/javascript">
        > > <!--
        > > Newsite=
        window.open("http://www.pa.msu.edu/services/","newsite");
        > > // -->
        > > </script>
        > >
        > > * sometimes, the "new" window is one of those already opened in
        the
        > session; this seems to be somewhat random, and I don't know if it's
        a
        > browser bug or a "JavaScript thing" with the window.open command.
        Just note
        > that browser behavior may not always be consistent if you use this
        script
        > (or the next one, which also uses window.open). -- GJP.
        > > This JavaScript example opens the new site in a new browser window
        after a
        > 4.5 second (4500 ms) delay:
        > > <script language="javascript" type="text/javascript">
        > > <!--
        > >
        >
        window.setTimeout('window.open("http://www.pa.msu.edu/services/","news
        ite")'
        > ,4500);
        > > // -->
        > > </script>
        > >
        > >
        > > WARNING: With these capabilities for automatic redirection to
        other web
        > pages, it is possible to set up a redirection loop -- try to avoid
        making it
        > a no-wait-time infinite loop! (An infinite loop with a reasonable
        delay, on
        > the other hand, might have its uses as a sort of slide show, among
        other
        > possibilities).
        > >
        > >

        > > OK, here's the changes and output. Still no redirect
        happening:
        > > --------------------------------------
        > > #!/usr/bin/perl
        > > use CGI;
        > > $|=1; # Turn on autoflush
        > > print "Content-type: text/html\n\n";
        > > print "<html><body>";
        > > print "Please wait, processing.";
        > >
        > > # file "stop" exists for this test...
        > > while (!-e "stop") {
        > > sleep 2;
        > > print " .";
        > > }
        > >
        > > print "<BR><BR>Done, processing......\n\n\n";
        > > print "</body></html><BR><BR>\n\n";
        > >
        > > # Create a new instance of CGI
        > > my $query = new CGI;
        > >
        > > # Get the URL to which the user should be directed
        > > my $target = "http://www.yahoo.com/";
        > >
        > > # Now redirect to the target
        > > print $query->redirect($target);
        > >
        > > exit;
        > >
        > > ----------------------------
        > > The result web page (source):
        > > ----------------------------
        > > Please wait, processing.
        > >
        > > Done, processing......
        > > <BR><BR>
        > >
        > > Status: 302 Moved
        > > Location: http://www.yahoo.com/
        > > ----------------------------
        > >
        > > Thanks again for the help.
        > > Scott
      • Franki
        Well, if worse comes to worse, you do have a way out.. print something like this into the html after the processing html:
        Message 3 of 6 , Mar 5, 2002
          Well, if worse comes to worse, you do have a way out..

          print something like this into the html after the "processing" html:

          <SCRIPT LANGUAGE ="JavaScript">
          <!--
          location.replace('http://www.mypage.com')
          //-->
          </SCRIPT>

          I think that works in all the browsers, and it doens't matter if a header
          was set or not because its not server side.

          Its better then nothing. I have used it myself a few times.


          rgds

          Frank



          -----Original Message-----
          From: scott.list [mailto:scott.list@...]
          Sent: Tuesday, 5 March 2002 10:58 AM
          To: Kyle Hamar; perl-beginner@yahoogroups.com
          Subject: [PBML] Re: Redirection


          Slow? Thats an understatement. I access the messages from their interface
          and it's been down completely all day (groups.yahoo.com).

          Thanks for the suggestion but it does not work either. It also says ". If
          you use redirection like this, you should not print out a header as well."

          In this app, the page (and the header of course) is already there. There's
          the issue, - can't redirect automatically after the page prints "Processing
          complete".

          Thanks,
          Scott

          ----- Original Message -----
          From: Kyle Hamar
          To: scott.list@...
          Sent: Monday, March 04, 2002 8:34 PM
          Subject: Redirection


          The list is slow tonight. (Sending via direct mail)


          Date: Mon, 04 Mar 2002 18:08:44 -0600
          To: perl-beginner@yahoogroups.com
          From: Kyle Hamar <khamar@...>
          Subject: RE: [PBML] [#2] cgi progressive displaying script ?

          direct from
          http://www.perldoc.com/perl5.6.1/lib/CGI.html#GENERATING-A-REDIRECTION-HEADE
          R

          GENERATING A REDIRECTION HEADER

          print $query->redirect('http://somewhere.else/in/movie/land');

          Sometimes you don't want to produce a document yourself, but simply
          redirect the browser elsewhere, perhaps choosing a URL based on the time of
          day or the identity of the user.
          The redirect() function redirects the browser to a different URL. If you
          use redirection like this, you should not print out a header as well.
          One hint I can offer is that relative links may not work correctly when
          you generate a redirection to another document on your site. This is due to
          a well-intentioned optimization that some servers use. The solution to this
          is to use the full URL (including the http: part) of the document you are
          redirecting to.
          You can also use named arguments:
          print $query->redirect(-uri=>'http://somewhere.else/in/movie/land',
          -nph=>1);

          At 11:13 PM 3/4/2002 +0800, you wrote:

          I thought redirects didn't work if you have already printed a header?


          rgds

          Frank

          -----Original Message-----
          From: msws_1 [mailto:scott.list@...]
          Sent: Monday, 4 March 2002 11:04 PM
          To: perl-beginner@yahoogroups.com
          Subject: Re: [PBML] [#2] cgi progressive displaying script ?


          > Try this and let me know if it works! ;-)

          OK, here's the changes and output. Still no redirect happening:
          --------------------------------------
          #!/usr/bin/perl
          use CGI;
          $|=1; # Turn on autoflush
          print "Content-type: text/html\n\n";
          print "<html><body>";
          print "Please wait, processing.";

          # file "stop" exists for this test...
          while (!-e "stop") {
          sleep 2;
          print " .";
          }

          print "<BR><BR>Done, processing......\n\n\n";
          print "</body></html><BR><BR>\n\n";

          # Create a new instance of CGI
          my $query = new CGI;

          # Get the URL to which the user should be directed
          my $target = "http://www.yahoo.com/";

          # Now redirect to the target
          print $query->redirect($target);

          exit;

          ----------------------------
          The result web page (source):
          ----------------------------
          Please wait, processing.

          Done, processing......
          <BR><BR>

          Status: 302 Moved
          Location: http://www.yahoo.com/
          ----------------------------

          Thanks again for the help.
          Scott









          [Non-text portions of this message have been removed]



          Unsubscribing info is here:
          http://help.yahoo.com/help/us/groups/groups-32.html

          Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
        • Kyle Hamar
          Frank, He got the code below to work. (Great minds think alike.) ... Kyle: Below worked like a charm. Web page prints with continuing .. until I create the
          Message 4 of 6 , Mar 5, 2002
            Frank,
            He got the code below to work. (Great minds think alike.)

            >Scott
            Kyle:
            Below worked like a charm. Web page prints with continuing ".." until
            I create the file called "stop". Then the script tacks on your Java.
            I used:
            print << "END"
            <script language="javascript" type="text/javascript">
            <!--
            window.setTimeout('window.location="http://www.yahoo.com/"',500);
            // -->
            </script>
            END
            Then the page redirects all by itself. Beautiful. Thanks very much
            for the help!
            Scott



            At 02:59 AM 3/6/2002 +0800, you wrote:
            >Well, if worse comes to worse, you do have a way out..
            >
            >print something like this into the html after the "processing" html:
            >
            ><SCRIPT LANGUAGE ="JavaScript">
            ><!--
            >location.replace('http://www.mypage.com')
            >//-->
            ></SCRIPT>
            >
            >I think that works in all the browsers, and it doens't matter if a header
            >was set or not because its not server side.
            >
            >Its better then nothing. I have used it myself a few times.
            >
            >
            >rgds
            >
            >Frank
          • Jenda Krynicky
            From: scott.list ... Aaagrrr. It says JavaScript here, not Java! DO NOT CONFUSE THE TWO! Jenda =========== Jenda@Krynicky.cz ==
            Message 5 of 6 , Mar 6, 2002
              From: "scott.list" <scott.list@...>

              > Kyle:
              >
              > Below worked like a charm. Web page prints with continuing ".." until
              > I create the file called "stop". Then the script tacks on your Java.
              > I used:
              >
              > print << "END"
              > <script language="javascript" type="text/javascript">

              Aaagrrr. It says JavaScript here, not Java!
              DO NOT CONFUSE THE TWO!

              Jenda

              =========== Jenda@... == http://Jenda.Krynicky.cz ==========
              There is a reason for living. There must be. I've seen it somewhere.
              It's just that in the mess on my table ... and in my brain.
              I can't find it.
              --- me
            • msws_1
              ... OK, OK. I m learning. Javascript it is.
              Message 6 of 6 , Mar 6, 2002
                > Aaagrrr. It says JavaScript here, not Java!
                > DO NOT CONFUSE THE TWO!
                >
                > Jenda

                OK, OK. I'm learning. Javascript it is.
              Your message has been successfully submitted and would be delivered to recipients shortly.