2 Replies Latest reply on Feb 15, 2007 11:17 PM by Newsgroup_User

    request and application scope remain undefined onApplicationStart

    <|Mantra|>
      Can anyone help me on this. I've created my Application.cfc file with the following:

      <cfcomponent displayname="myName" output="false">

      <cfset this.name = "applicationName">
      <cfset this.applicationTimeout = CreateTimeSpan(0, 0, 20, 0)>
      <cfset this.scriptProtect = "all">

      <cffunction name="onApplicationStart" output="false">
      <cfset request.dsn = "codeLib">

      </cffunction>

      <cffunction name="onRequestStart" returntype="void" output="true">
      <cfinclude template="header.cfm">
      </cffunction>

      <cffunction name="onRequestEnd" returntype="void" output="true">
      <cfinclude template="footer.cfm">
      </cffunction>

      </cfcomponent>

      But when i try to make a db call on my page i get an "Element DSN is undefined in REQUEST", same as with application.dsn. Is the application not starting or something ??

      Thx heaps
        • 1. Re: request and application scope remain undefined onApplicationStart
          MichaelSJudd Level 1
          Mantra,

          I don't actually see a cfapplication header, so I don't think request.dsn or application.dsn would be set (or processed as special variables). I think CF is assuming a query name of "request" or "application", and of course those queries do not exist, so the variables specified don't exist.

          - Mike
          • 2. Re: request and application scope remain undefined onApplicationStart
            Level 7
            > <cffunction name="onApplicationStart" output="false">
            > <cfset request.dsn = "codeLib">
            >
            > </cffunction>
            >

            > But when i try to make a db call on my page i get an "Element DSN is undefined
            > in REQUEST", same as with application.dsn. Is the application not starting or
            > something ??

            You shouldn't be setting REQUEST-scoped variables in the
            onAPPLICATIONStart() method. That method only gets called once per
            lifetime of the application, so any request-scoped variables will only be
            set for the first request of the lifetime of the app (so like the first
            page hit after the CF server restarts, for that particular application).

            Request variables need to be set... every request. So probably best to set
            them in onREQUESTStart().

            --
            Adam