• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

request and application scope remain undefined onApplicationStart

New Here ,
Feb 15, 2007 Feb 15, 2007

Copy link to clipboard

Copied

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
TOPICS
Advanced techniques

Views

325

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 15, 2007 Feb 15, 2007

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 15, 2007 Feb 15, 2007

Copy link to clipboard

Copied

LATEST
> <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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation