Check to see if a page exists?

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default Check to see if a page exists?

    Is there a way that I can check to see if a page exists? I was thinking it
    might be possible with CFHTTP or something along those lines but am not sure.

    I am working on a web app and there is a part where it creates a path base on
    a string and I need to be able to verify if the path is valid so that i can
    redirect is as appropriate if it is not.

    Please Help!!!

    Josh

    jeby Guest

  2. Similar Questions and Discussions

    1. Creating a URL still exists page/util
      Hi All Quite familiar with ASP and JavaScript and wondered if there is a method out there that allows me to create a web page util to see if URL...
    2. check if a recordset exists
      in asp is there a way to determine wether a recordset exists or not . the problem is i have On Error Resume Next on my page and if duff data is...
    3. Check if table exists
      ON.KG wrote: One thing to consider: you are making a trip to the database to determine if a table exists. If it exists, you are then making...
    4. HOW TO: check if a URL exists or not - ErROR 404 ?
      My php passes through some links. But I want to redirect if the URL does not exist. How best to check if a URL is there or not? Thanks, gsb
    5. how to check if a process still exists in a C app
      I have the process id. I want to check if it is still running. What is the best (and fastest) way to do this? (for HPUX, AIX, Linux) I can...
  3. #2

    Default Re: Check to see if a page exists?

    Hi Josh,

    CFHTTP will do what you want, just check CFHTTP.errorDetail or
    CFHTTP.responseHeader.status_code after the call. BUT, if this is a path to
    a file on the local file system, you can also use CFDIRECTORY or CFFILE (if
    you know a file that is sure to be in the path). Just some ideas.

    HTH and good luck!

    --
    Best Regards,
    Chris

    "jeby" <webforumsuser@macromedia.com> wrote in message
    news:d9cdp4$evu$1@forums.macromedia.com...
    > Is there a way that I can check to see if a page exists? I was thinking
    > it
    > might be possible with CFHTTP or something along those lines but am not
    > sure.
    >
    > I am working on a web app and there is a part where it creates a path base
    > on
    > a string and I need to be able to verify if the path is valid so that i
    > can
    > redirect is as appropriate if it is not.
    >
    > Please Help!!!
    >
    > Josh
    >

    Sir Monkey \(Chris L.\) Guest

  4. #3

    Default Re: Check to see if a page exists?

    is that an internal or external page?

    jorgepino Guest

  5. #4

    Default Re: Check to see if a page exists?

    I'm gonna give this a try, i need to loop through hundreds of URLs automatically...any suggestions on when to timeout and move to the next site or how to error check it?
    flasheister Guest

  6. #5

    Default Re: Check to see if a page exists?

    in response to chris....

    So, If i do CFHTTP and get no error then it exists?

    in respons to jorgepino...

    It is an internal page. I am writing an application that creates a file path
    from a string that is passed in the URL. I want to be able to forward the page
    to a default path if the page the string points to does not exist...

    I dont know if this will be of any extra help to anyone.

    My other idea is so possibly catch the error with a <CFTRY> and a <CFCATCH>
    but I do not know how to use that tag and have been fairly unsuccessful with it
    in the past. If someone could tell me if it would work and how to do it i
    would appreciate it.

    Thanks everyone! All suggestions are helpful!

    josh

    jeby Guest

  7. #6

    Default Re: Check to see if a page exists?

    On 2005-06-22 19:47:34 -0500, "jeby" <webforumsuser@macromedia.com> said:
    > in response to chris....
    >
    > So, If i do CFHTTP and get no error then it exists?
    >
    > in respons to jorgepino...
    >
    > It is an internal page. I am writing an application that creates a
    > file path from a string that is passed in the URL. I want to be able
    > to forward the page to a default path if the page the string points to
    > does not exist...
    >
    > I dont know if this will be of any extra help to anyone.
    >
    > My other idea is so possibly catch the error with a <CFTRY> and a
    > <CFCATCH> but I do not know how to use that tag and have been fairly
    > unsuccessful with it in the past. If someone could tell me if it would
    > work and how to do it i would appreciate it.
    > Thanks everyone! All suggestions are helpful!
    >
    > josh
    If these are all local pages and I understand what you're getting at,
    you could use FileExists() to check for the existence of the file.

    Matt
    --
    Matt Woodward
    [email]mpwoodward@gmail.com[/email]
    Team Macromedia - ColdFusion

    mpwoodward *TMM* Guest

  8. #7

    Default Re: Check to see if a page exists?

    quickest way for an internal file is :

    <cfdirectory action="list" filter="#fileName#" directory="#filePath#"
    name="checkFile">
    <cfif checkFile.recordcount neq 0>
    FileExists
    <cfelse>
    No File, YOU LOSE!
    </cfif>

    cheers,
    Aegis

    A3gis Guest

  9. #8

    Default Re: Check to see if a page exists?

    FileExists(ExpandPath(yourfile)) Boolean yes or no

    <cfif FileExists(ExpandPath(yourfile))>
    <p>Your file exists in this directory. You entered
    the correct file name, #GetFileFromPath("#thisPath#/#yourfile#")#
    <cfelse>
    file not found
    </cfif>

    jorgepino Guest

Posting Permissions

  • You may not post new threads
  • You may 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