Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

It's a bit unclear to me what exactly you're trying to do. I'm going to fathom a guess, including some hand-waving, and you'll have to tell me if I'm on the right track.

You have a CGI script running on a machine named "www.domain.com". The CGI script is "a.pl". Currently, "a.pl" returns a redirect to Pg B. After that, it doesn't currently know anything.

Meanwhile, Pg B is really "b.pl", which issues a redirect to c.pl, which issues a redirect to d.pl.

What you want to do is figure out where b.pl is really going to go, and just issue the redirect directly to the last place.

If this is a correct guess on what you're looking for, my humble suggestion is "don't." As in, don't short-circuit this. It's incredibly error-prone in the general case, and mildly annoying in specific cases where there is a general-purpose tool available to do it for you (i.e., the browser).

There are a number of ways to be redirected. The most obvious is a "page moved" response. There's also meta-redirect tags, or even Javascript. Do you want/need to handle all of these?

Further, Pg B (or Pg C) may or may not be a script (you can't always tell - just because it ends with ".html" doesn't mean it's not dynamic). And they may do different redirections based on cookies the user has ("not authorised - go away"). Or they may do other processing ("User clicked on 'pg b' in a form that needs some other processing - send them to pg c so that it can be processed, then pg c figures out that there's stuff missing, so sends the user to an error page, page d"). There is a lot of context that you need to be aware of. Allowing the browser to do it means that you can really simplify the code and ensure everything is correct easier.

That said, if all of this really lived inside the same set of perl modules, you could simply call the other pages directly and let them figure out what to do. This would be relatively simple in CGI::Application, as it would, I'm sure, under a number of other systems. Just call the next function directly - you save a lot of processing (both the client and the server) and associated network overhead this way. But the key here is to call the worker functions that are identical whether you're redirecting or just calling the next function in the series (except for a decision point on whether to redirect or call the next function). Again, this can simplify your workload as the developer while still saving that extra overhead for the server and the user.


In reply to Re: Is it possible to get the redirected URL? by Tanktalus
in thread Is it possible to get the redirected URL? by weilies

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2024-04-26 00:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found