Professional Web Applications Themes

Server side redirect CFMX6.1 - Coldfusion - Advanced Techniques

I tried this very simple piece of code just to verify if i can get a serverside redirect to work: <cfscript> getpagecontext().forward("http://www.google.com"); </cfscript> But it doesn't work. It gives the following error: /tst/http:/www.google.com Where /tst is actually the subdir where the script holding the redirect is located. If i just put in a script that is also located in the /tst directory instead of http://www.google.com it will work well! Am i missing something? Any ideas how to get this working?...

  1. #1

    Default Server side redirect CFMX6.1

    I tried this very simple piece of code just to verify if i can get a serverside
    redirect to work:

    <cfscript>
    getpagecontext().forward("http://www.google.com");
    </cfscript>

    But it doesn't work. It gives the following error:

    /tst/http:/www.google.com

    Where /tst is actually the subdir where the script holding the redirect is
    located. If i just put in a script that is also located in the /tst directory
    instead of http://www.google.com it will work well! Am i missing something? Any
    ideas how to get this working?

    droopcat Guest

  2. #2

    Default Re: Server side redirect CFMX6.1

    > getpagecontext().forward("http://www.google.com");

    Would would you actually expect to happen if somehow having a SERVER-side
    redirect going to an location external to the server itself (eg: google in
    your example)? How would you expect that to work? What would you expect
    to happen?

    A server-side redirect is for redirecting processing to a different place
    *on that server*.

    You want to use a CLIENT side redirect. Use <cflocation>.
    --
    Adam
    Adam Guest

  3. #3

    Default Re: Server side redirect CFMX6.1

    If the only objective is a server side re-direct, <cflocation> does that very
    well.


    Originally posted by: droopcat
    I tried this very simple piece of code just to verify if i can get a
    serverside redirect to work:

    <cfscript>
    getpagecontext().forward("http://www.google.com it will work well! Am i
    missing something? Any ideas how to get this working?



    Dan Guest

  4. #4

    Default Re: Server side redirect CFMX6.1

    Are you sure? I think that <cflocation> is actually not doing a real serverside redirect! It sends back redirect headers to the users browser so it's still a client-side redirect after all....
    droopcat Guest

  5. #5

    Default Re: Server side redirect CFMX6.1

    PageContext.forward():


    http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/jsp/PageContext.html#forward
    (java.lang.String)

    This method is only applicable to pages inside the same domain. You can't do
    what you're attempting with the forward() call.

    " This method is used to re-direct, or "forward" the current ServletRequest
    and ServletResponse to another active component in the application.

    If the relativeUrlPath begins with a "/" then the URL specified is calculated
    relative to the DOCROOT of the ServletContext for this JSP. If the path does
    not begin with a "/" then the URL specified is calculated relative to the URL
    of the request that was mapped to the calling JSP. "


    Kronin555 Guest

  6. #6

    Default Re: Server side redirect CFMX6.1

    Dan Bracuk wrote: 

    cflocation is a client-side redirect.

    --
    Matt Woodward
    com
    Team Macromedia - ColdFusion
    mpwoodward Guest

  7. #7

    Default Re: Server side redirect CFMX6.1

    Thanks all and especially Kronin555, that is useful information.

    Actually i came to this subject because there is an example in the
    "Discovering Fusebox 4 with coldfusion, 2nd edition" book for the fusebox
    <relocate> tag, which has an attribute "type" which can be set to "client" or
    "server" and in their example they use a serverside redirect to another
    domain.... which will never work because internally Fusebox uses the
    getpagecontext().forward function.

    droopcat Guest

Similar Threads

  1. read server side file from clent side
    By sapna30 in forum Macromedia Flash Flashcom
    Replies: 3
    Last Post: February 12th, 11:49 PM
  2. flashcom: client side cant access server side
    By u_sq in forum Macromedia Flash Flashcom
    Replies: 1
    Last Post: June 28th, 09:16 PM
  3. Newbie question - Server side redirect
    By John in forum PHP Development
    Replies: 2
    Last Post: January 16th, 01:30 AM
  4. Controls with a client side onLoad function or seting a cursor server side
    By Geoff Davis in forum ASP.NET Building Controls
    Replies: 3
    Last Post: January 15th, 03:54 AM
  5. button evet ---- server side - client side ???
    By yaya coco in forum ASP.NET General
    Replies: 1
    Last Post: July 4th, 10:58 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139