Skip navigation
johnny_perez_new
Currently Being Moderated

Include's relative link problem

May 24, 2012 11:27 AM

I am doing this on dreamweaver cs4 on my application.cfm page I have the following script 

 

On the page that i'm using the include I have down      I have tried that and several variations and I keep getting an error which says Element BASEPATH is undefined in APPLICATION.  how can i resolve this? 

 
Replies
  • Currently Being Moderated
    May 24, 2012 12:47 PM   in reply to johnny_perez_new

    Your post appears to be incomplete.

     
    |
    Mark as:
  • Currently Being Moderated
    May 24, 2012 3:40 PM   in reply to johnny_perez_new

    Right before that line, cfdump your application scope to see if the variable is there.

     

    The problem might be that your application does not have a name.

     
    |
    Mark as:
  • Currently Being Moderated
    May 25, 2012 4:58 AM   in reply to johnny_perez_new

    johnny_perez_new wrote:

     

    I did that I added a name to the application.cfm "<cfset this.name=testname>" and then put "<cfdump var="#application#">" before the include and the application name was there and I enabled robust debugging which said that the error is from the <include template="#application.basePath#master.cfm" /> is there any other method to include a relative link that might work..

    Ensure the name of your application file starts with capital A. Also, let the cfapplication tag at least have the following attributes:

     

    <cfapplication name="testname"

        sessionmanagement="Yes"

        sessiontimeout="#createTimeSpan(0,0,20,0)#"

        applicationtimeout="#createTimeSpan(1,0,0,0)#">

     
    |
    Mark as:
  • Currently Being Moderated
    May 25, 2012 5:02 AM   in reply to johnny_perez_new

    <cfapplication>

    <cfset application.basePath= GetDirectoryFromPath(CGI.SCRIPT_NAME)>

    </cfapplication>

    I suspect it is incorrect to use the cfapplication tag in this way. See my previous example.

     
    |
    Mark as:
  • Currently Being Moderated
    May 25, 2012 5:11 AM   in reply to BKBK

    Ensure the name of your application file starts with capital A. Also, let the cfapplication tag at least have the following attributes:

     

    <cfapplication name="testname"

        sessionmanagement="Yes"

        sessiontimeout="#createTimeSpan(0,0,20,0)#"

        applicationtimeout="#createTimeSpan(1,0,0,0)#">

     

    I think your subsequent post is the one that's important, but just on this one: the only attribute one needs is the name.  Session activation is only needed if one needs sessions, and the timeouts are only needed if they vary from what's in CFAdmin already.

     

    Strictly speaking even the name is not required, but it's bad form not to have one.

     

    But it's the improper use of <cfapplication> as a nestable tag that's most likely the problem here.

     

    --

    Adam

     
    |
    Mark as:
  • Currently Being Moderated
    May 25, 2012 7:12 AM   in reply to johnny_perez_new

    Your cfdump shows that application.basePath is not being set by your Application.cfm page.  It's just as well.  Your approach makes it possible for user A to set the variable, user B to change it, and then user A uses the wrong value.

     

    I suggest changing Application.cfm to Application.cfc.  Then set your variable in the OnRequestStart function.  Also, don't make it an application variable.  Off the top of my head I can't think of the most appropriate scope, but you should be able to figure it out.

     
    |
    Mark as:
  • Currently Being Moderated
    May 25, 2012 11:50 PM   in reply to Adam Cameron.

    Adam Cameron. wrote:


    I think your subsequent post is the one that's important, but just on this one: the only attribute one needs is the name.  Session activation is only needed if one needs sessions, and the timeouts are only needed if they vary from what's in CFAdmin already.

     

    Strictly speaking even the name is not required, but it's bad form not to have one.

    All true. However, I was thinking of something else. As Johnny_Perez_New seems to be unfamilar with cfapplication, I wished to introduce the tag with its most commonly used attributes.

     
    |
    Mark as:
  • Currently Being Moderated
    May 25, 2012 11:54 PM   in reply to Dan Bracuk

    Dan Bracuk wrote:

     

    Your cfdump shows that application.basePath is not being set by your Application.cfm page.  It's just as well.  Your approach makes it possible for user A to set the variable, user B to change it, and then user A uses the wrong value.

    That isn't the case here, Dan. Application.basePath is a CGI variable which, we may assume, cannot be changed by the user.

     
    |
    Mark as:
  • Currently Being Moderated
    May 26, 2012 12:07 AM   in reply to BKBK

     

    Your cfdump shows that application.basePath is not being set by your Application.cfm page.  It's just as well.  Your approach makes it possible for user A to set the variable, user B to change it, and then user A uses the wrong value.

    That isn't the case here, Dan. Application.basePath is a CGI variable which, we may assume, cannot be changed by the user.

     

    I see what Dan's on about.

     

    Say a user hits /some/path/to/a/file.cfm, then application.basePath will be /some/path/to/a/.  Now a different user hits /some/path/to/a/different/file.cfm, the variable will be /some/path/to/a/different/.

     

    This is not the sort of thing one wants setting on a request by request basis, which is what's gonna happen in Application.cfm

     

    The variable should not:

    a) be set via a request-centric setting such as a CGI-scoped variable

    b) reset every request.

     

    Surely the base path is known to the application code, so it should just be hard-coded?

     

    I'd also recommend using Application.cfc over Application.cfm.  Whilst not specifically stated, Appliction.cfm is an obsolete approach to application / request management.

     

    --

    Adam

     
    |
    Mark as:
  • Currently Being Moderated
    May 26, 2012 4:22 AM   in reply to Adam Cameron.

    Adam Cameron. wrote:

     

     

    Your cfdump shows that application.basePath is not being set by your Application.cfm page.  It's just as well.  Your approach makes it possible for user A to set the variable, user B to change it, and then user A uses the wrong value.

    That isn't the case here, Dan. Application.basePath is a CGI variable which, we may assume, cannot be changed by the user.

     

    I see what Dan's on about.

     

    Say a user hits /some/path/to/a/file.cfm, then application.basePath will be /some/path/to/a/.  Now a different user hits /some/path/to/a/different/file.cfm, the variable will be /some/path/to/a/different/.

    If the applicationtimeout value is substantial then, as long as the application doesn't restart, the variable will remain unchanged. However, the first user to open the application determines the value for subsequent users. So there's no escaping the argument from you and Dan. I sincerely overlooked the intricacies.

     
    |
    Mark as:
  • Currently Being Moderated
    May 26, 2012 5:50 AM   in reply to BKBK

    The code in question is a , and it's bring called every request.

     

    --

    Adam

     
    |
    Mark as:
  • Currently Being Moderated
    May 27, 2012 12:04 AM   in reply to Adam Cameron.

    Adam Cameron. wrote:

     

    The code in question is a , and it's bring called every request.

     

     

    Oh FFS these forums are pathetic.

     

    What I actually posted was this:

     

    The code in question is a <cfset> in Application.cfm. The variable will be re-set every request. Application.cfm had no special application-centric properties (it's misnamed, it should be called OnRequestStart.cfm), so it doesn't matter about application timeouts: a <cfset> is a <cfset>, and it's [being] called every request.


    I shouldn't have attempted to respond by email, I guess.

     

    --

    Adam

     
    |
    Mark as:
  • Currently Being Moderated
    May 27, 2012 1:03 AM   in reply to Adam Cameron.

    Adam Cameron. wrote:

     

    What I actually posted was this:

     

    The code in question is a <cfset> in Application.cfm. The variable will be re-set every request. Application.cfm had no special application-centric properties (it's misnamed, it should be called OnRequestStart.cfm), so it doesn't matter about application timeouts: a <cfset> is a <cfset>, and it's [being] called every request.


    I shouldn't have attempted to respond by email, I guess.


    No problem: it was obvious something went wrong on the wire.

     

    Thanks for pointing that out. I can now see the confusion arose from an omission on my part. By the time I wrote my last post, at least 2 recommendations had been made to the poster to switch to Application.cfc. (which I incidentally also strongly support). I therefore implicitly had Application.cfc and onApplicationStart in mind. The assumption is therefore that the application variable is initialized in onApplicationStart.

     

    Otherwise my point about a restart becomes absurd, to say the least. I hope this explanation clarifies that passage. Even if you switch to Application.cfc, initializing the application variable in onApplicationStart, you still won't escape the dilemma of one user setting a path for others.

     
    |
    Mark as:
  • Currently Being Moderated
    May 27, 2012 1:22 AM   in reply to johnny_perez_new

    @Johnny_Perez_New

     

    You could start with a basic Application.cfc like the following, and fill in the details later where needed:

     

    <cfcomponent>

        <cfscript>

            this.name = "testname";

            this.applicationTimeout = "#createTimespan(1,0,0,0)#";

            this.sessionManagement = "true";

            this.sessionTimeout = "#createTimeSpan(0,0,20,0)#";

        </cfscript>

       

        <cffunction name="onApplicationStart" returntype="boolean">

                <!--- Initialize application variables here --->

            <cfreturn true>

         </cffunction>

        

        <cffunction name="onSessionStart">

          

            </cffunction>

     

        <cffunction name="onRequestStart">

         <cfargument name = "targetPage" type="String" required="yes">

              <!--- Initialize variables here that you wish to be available to every request --->

          <!--- This is therefore not the place to set application or session variables --->

         </cffunction>

     

        <cffunction name="onRequestEnd">

           <cfargument type="String" name = "targetTemplate" required="yes">

       

        </cffunction>

     

        <cffunction name="onSessionEnd">

           <cfargument name = "SessionScope" required="yes">

           <cfargument name = "AppScope" required="yes">

          

              <cflog file="#This.Name#" type="Information" text="Session: #arguments.SessionScope.sessionid# ended">

        </cffunction>

     

         <cffunction name="onApplicationEnd">

           <cfargument name="ApplicationScope" required="yes">  

          <cflog file="#This.Name#" type="Information"

              text="Application #ApplicationScope.applicationname# Ended">

        </cffunction>

    </cfcomponent>

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points