Application Variables

Hi!,
Pl. tell me how to create a Application Variable and how to use it in application.

write specifically, what r u want to do
bye,
Samir

Similar Messages

  • Problem with application-variables - CFLOCK?

    Hi,
    i have a problem with my application. It is a multi-user
    application with 100 parallel-users and CFMX 7.
    The problem wich occures is with application variables. These
    are mainly structs wich get filled onApplicationStart(). The
    problem is, that the variables suddenly disappear, they are empty.
    I have read about CFLock and found out, that it is necesseary
    to use cflock. And i found out, that onApplicationStart does
    correct locking automatically. That is where i do not understand
    the problem. The variables get intialized correctly and in further
    they only get read-access. Why can they be corrupted?
    My other question about that is, wheather i need cflock for
    all Read-Access to Application and Session-Variables, even if there
    happens no writing to the variables?
    Best Regards,
    Andreas

    > ?The element of position 2, of dimension 2, of an array
    object used as part of
    > an expression, cannot be found.?
    > The array is in this case the struct.
    Well, OK, that could be a problem. Arrays are not structs:
    they are two
    different things, are not interchangeable, and have
    completely different
    sets of functions to utilise them. You cannot treat a struct
    as an array.
    If CF is claiming your "struct" is an array, then it actually
    *is* an
    array, not a struct.
    What's the line of code which is generating that error?
    I suppose one could get this error if you have an array of
    structs thus:
    myArray
    .key1
    myArray.key2
    (etc)
    and you're trying to reference it with a numeric key rather
    than by key
    name, eg:
    myArray
    [n]
    When n is an integer value, rather than a string (which
    corresponds to the
    name of the key).
    > > Have you trapped the error, done a <cfdump>
    of the application scope and
    > > checked to see if it's the whole lot going awry, or
    just some values?
    > I have not used cfdump for it, because the server had to
    be immediately
    > restarted for our customers. But i think, that it is
    not completely empty,
    > because the index runs to pos2 of dimenstion2.
    So does this not happen in your dev / testing environment?
    > Will
    > onApplicationStart() be called before? Or only if
    onRequestStart() returns true?
    I would ***-u-me that the application one would be called
    before the
    request one. It's pretty easy for you to test this though, I
    should think?
    (Sorry: for reasons beyond the scope of this conversation,
    we're still
    forced to use Application.cfm in our software, so I've only a
    passing
    knowledge of how Application.cfc works).
    > Here is the code from onRequestStart()
    > <cffunction name="onRequestStart"
    returntype="boolean">
    > <cfargument name="Requestedpage" required="yes" />
    > <cfscript>
    > var lFile = "/cargorent/Login.cfm";
    > var iPosn = ListFindNoCase( lFile,
    Arguments.Requestedpage );
    > if( iPosn gt 0 )
    > return true;
    >
    > if( NOT IsDefined( "session.user.Loginname" ) or
    session.user.Loginname eq
    > "" )
    > {
    > WriteOutput( "<p><p> The current user is no
    longer valid, please log in
    > again.</p></p>" & chr(10) & chr(13)
    > WriteOutput( "<script
    language=""javascript"">parent.location = ""
    http://"
    > & CGI.HTTP_HOST &
    "/Login/Login.cfm"";</script>" );
    > return false;
    > }
    >
    > return true;
    > </cfscript>
    > </cffunction>
    One thing I will say here is that I really think you should
    be separating
    your processing from your display. A function should do
    processing. it
    should pass that processing back to a CFM template which
    should handle
    whatever needs to be displayed on the browser. Although
    that's nowt to do
    with your current issue.
    Adam

  • How to Create and Use Application Variables in Java

    I Have this need to have a common variable (Counter) for all the users(Sessions) accessing my Site witch is in JSP.
    I think An Application Variable is the solution for my problem...
    But I don't know how to use this. Even though I search the web for any tutorials or Examples could not fing any.
    Could any one Please tell me or direct me to a site which has good information about this
    Thanks In Advance!!!
    Badsy.

    // get the application object
    public class myServlet extends HttpServlet
    public void doGet(HttpServletRequest req,
                        HttpServletResponse res)
    ServletContext application = getServletContext();
    }

  • Performance: Database Update vs. Application variable

    I am new to ColdFusion, so sorry if this has been covered before. I searched and couldn't find anything similar.
    I am building an online Texas Hold'em poker application using ColdFusion and Flex. There are quite a few things that need to be stored on the server side that will be updated quite often and these objects will need to be accessed by multiple users. For example, think of something like the current pot between players on a table, or the current hand state (who's turn it is to check/bet/raise), or the current players in the hand. All of these things will be updated quite a few times per hand, and if you add to that that each of these will be different per table, it adds up quick.
    Would it be better to store these things in the database or store them in an application variable? Or is there a better way that I am not thinking of? Is there any sort of metric to follow for these kinds of things?

    I don't think you'll find a documented general number of application variables you can have on a single server. But I think you could get away with 400 variables without any trouble.
    Where you might run into trouble, though, is when you have multiple concurrent requests trying to read and change these values. You'll have to ensure that you single-thread write access to these variables using CFLOCK.
    Dave Watts, CTO, Fig Leaf Software
    http://www.figleaf.com/
    http://training.figleaf.com/
    Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on
    GSA Schedule, and provides the highest caliber vendor-authorized
    instruction at our training centers, online, or onsite.

  • Application Variables in application.cfm and asp

    If anyone could provide some insight into using application
    variables declared in application.cfm, but retrieved in asp code,
    it would be appreciated.
    GOAL: Retrieve values into an asp page from application
    variables in application.cfm.
    PROCESS: Defined the variables in application.cfm. On an asp
    page, defined the application variable in Window -> Bindings.
    The application variables defined in the source code show up.
    Attempt to retrieve the application variable in the asp page by
    using the command: var_destination = Application("var_name")
    It seems like whatever I try, the variable is empty. After
    looking around on the web, I also saw that the equivalent to
    application.cfm in asp is global.asa. I also tried setting up this
    file, along with the variables, did the binding, and used the same
    commands, and also was not able to retrieve any application
    variables.
    What am I missing?

    What am I missing?
    That ColdFusion and ASP.NET are different applications and do
    not share
    the same memory addresses So they are going to each have
    their one
    "application" variables.
    Blue Dragon has implemented CFML as an ASP.NET language so
    that one
    could write ColdFusion that runs on the ASP.NET framework and
    would then
    use the same memory locations with their server.
    Otherwise you are going to have to write your own sharing
    tool. Some
    code that can read the desired variables from one code base
    and pass it
    to the other code base through forms, web services or some
    other manner.

  • Sometimes application variables don't reset

    In our application.cfm, many queries are run and set to arrays that are application scope. They are for code tables. To keep all this from happenning each time a template runs, there is a server scope variable that is set to true from another program and in application.cfm, there is something like <cfif the server variable is true> run queries,assign arrays,set server variable to false  </cfif>.
    When a new code is added to a code table, we set the server variable to true and the next template that runs resets all the application variables and the new code is in one of them.
    Sometimes this doesn't work. Only some of the arrays get reset and the others are empty. The arrays are there but have no elements.
    Repeating the process 2 to 4 times seems to make it work.
    What can cause it not to work the first time ?

    The problem happens even in a test area where I'm the only one using it.
    Why does the reset program sometimes have to be run more than once ?
    This is the reset program
    server.x=0
    This is what the application.cfm is like
    <cfapplication name="thename">
    <cfset ds="dsname">
    <cfparam name=server.x type="boolean" default="0">
    <cfif server.x eq 0>
       <cfset server.x=1>
       <cfset application.codes=arraynew(2)>
       <cfquery name="qcodes" datasource="#ds#">
          select codes, desc from tblcodes order by codes
       </cfquery>
      <cfloop query="qcodes">
          <cfset application.codes[currentrow][1]=qcodes.code[currentrow]>
          <cfset application.codes[currentrow][2]=qcodes.desc[currentrow]>
          <cfset application.codes[currentrow][3]=qcodes.place[currentrow]>
          <cfset application.codes[currentrow][4]=qcodes.date_eff[currentrow]>
          <cfset application.codes[currentrow][5]=qcodes.date_del[currentrow]>
      </cfloop>
       does this for well over 50 more tables
    </cfif>

  • Are application variables 'user specific'?

    hi - i've got a feeling i may have done something stupid.
    we have several domains all pointing to one application.
    in application we look at the cgi.http_host to work out which
    site the domain the user is expecting and then serve up customised
    content accordingly.
    only this is i've set put the customised content in
    application scoped vars - is that a bad move?
    eg. in application.cfm i have:
    <cfif cgi.http_host eq 'www.redredred.com' >
    <cfset application.message= "welcome - we love the colour
    red" >
    <cfelseif cgi.http_host eq 'www.blueblueblue.com' >
    <cfset application.message= "welcome - to our site where
    we love blue" >
    <cfelse>
    <cfset application.message= "welcome to our site (we love
    all colours)" >
    </cfif>
    then in the index.cfm:
    <cfoutput>#application.message#</cfouput>
    is there a chance that by doing this someone who has visited
    www.redredred.com will get a message about blue?

    happysailingdude wrote:
    >
    > is there a chance that by doing this someone who has
    visited www.redredred.com
    > will get a message about blue?
    >
    Not only a chance, but there is something wrong if the person
    does not
    get this message, once the next user has set the variable to
    blue.
    Application variables are global to the application and will
    be shared
    by all users of that application. That is the designed and
    desired
    purpose of application variables.
    In ColdFusion an application is defined by any template that
    shares the
    same 'name' as defined in either the name parameter of a
    <cfapplication...> tag or the this.name property of an
    Application.cfc file.
    If all these web sites are using the same string for the
    application
    name then they share the same application scope and they will
    all have
    the same value for application.message. And this value will
    be the
    value set by the last visitor to any of the sites.
    <cflock...> is not relevant to this issue. It will
    prevent the variable
    from being set at the exact same moment by multiple users on
    multiple
    sites, but it will not stop the value from changing
    sequentially as
    first one, then another user visits any of these sites and
    changing the
    value.
    The solution to your problem is to set different application
    scopes by
    dynamically setting the application name. Thus each website
    will be
    separate and distinct applications with their own application
    scope
    variables and your system should behave the way desired.

  • Global Application variable

    How do I set a global application variable in a Swing application?
    Namely
    MDI display opens a new window
    new window sets a variable
    close the new window and return to the MDI window
    MDI window needs to use the variable.
    Note: the new window is is its own class object.

    What are you talking about?
    Static variables are "global".
    In some class (it does not really matter which) define
    a static variable. O.K. now you have a "global"
    variable.
    Some people may say that this is "bad" programming
    practice, but it is what you asked for.public static variables of public classes are 'global' in the sense you can refer to them if anywhere in an application. Public classes are also 'global' in this sense.
    However, we don't call them global variables, they are class variables. A global variable is generally defined to be one that is associated with the running application. It has no context other than that. It can be used anywhere at any time without any qualifications. In other words, the are terrible.
    I had to maintain an application that had 50 or so global variables. Some of these variables represented the exact same piece of information so it was cruicial during modifications to make sure that they were kept in sync. Don't use this type of design.

  • About JSP's application variables

    Hi,
    I want to use some XML files in my project for which i have got some URLs. Now there are two ways to use the files. The first is that i get these XML files from their particular URLs and store them into application variable, while the second way is, i save them into my disk and use it from disk only. Now i want to know, which one is the best solution.......storing in application variable or storing on disk?

    Thanx for your suggestion...
    I have around 10-15 MBs of XML files. I just want to
    know the access time of getting it from Disk or
    getting it from application variable. Which one is
    best in regards of access time?Well it depends on how you are trying to access it and what you are accessing. You could use the DOM parser which stores it in memory anyway or the SAX parser , or you could process it with XSLT.
    Either ways, you can test the speed yourself. Just use a Java Probing tool to measure performance.

  • Application variables don't work!

    I am using COLDFUSION MX 7.
    There are 2 files:
    Application.cfc
    and
    test.cfm
    Application.cfc:
    ==================
    <cfcomponent output="no" displayname="test">
    <cfset THIS.name="test0">
    <cfset application.testvariable="teststring">
    </cfcomponent>
    ==================
    Test.cfm
    <cfdump var="#application.testvariable#">
    RESULT
    ==================
    Element TESTVARIABLE is undefined in APPLICATION.
    QUESTION
    ==================
    How do I use application variables?
    Note: my Application file is a cfc not a cfm because I'm
    trying to use MX 7 (and want to use functions such as onSessionEnd
    etc.)
    Thanking you in advance,
    Mitja Giaconi

    QUESTION
    ==================
    How do I use application variables?
    Note: my Application file is a cfc not a cfm because I'm
    trying to use
    MX 7 (and want to use functions such as onSessionEnd etc.)
    Good, then you can start by using onApplicationStart which is
    the first
    event where application variables can be set.
    <cffunction name="onApplicationStart" ...>
    <cfset application.testvariable="teststring">
    </cffunction>
    Livedocs information on all things Application.cfc
    http://www.adobe.com/livedocs/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/html/wwhelp.htm? context=ColdFusion_Documentation&file=part_cfm.htm

  • Same Application Variables name in different websites on the same server.

    Hi,
    I have two websites in the same server that use both their own Application.cfm file.
    In each Application.cfm file is defined the application variable Application.DB
    In website1 the Application.DB = DB1
    In website2 the Application.DB = DB2
    Since I'm studying Application.CFC solution, and I did read that application variables with same name have as scope the entire server ... I'm a bit worried. This happen also with Application.CFM ?

    Since I'm studying Application.CFC solution, and I did read that application variables with same name have as scope the entire server ... I'm a bit worried. This happen also with Application.CFM ?
    That's not quite how it works.  Each application has its own name, and application.foo on one application (name) is a different variable from application.foo within a different application (name).
    Reading these sections of the docs might help:
    Configuring and using application variables:
    http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec0c35c -7fec.html
    cfapplication:
    http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7d 69.html
    About applications:
    http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec0b63c -7fda.html
    Defining the application and its event handlers in Application.cfc:
    http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24 -7d39.html
    You should definitely be using Application.cfc, not Application.cfm, btw.
    Adam
    Adam

  • Problems getting application variables to work

    I basically want to alternate a message when a page is
    loaded. First time loaded, message a. Second time loaded, message
    b.
    I have a database table (testCount) holding one row in one
    column (theCount) and have tried the code attached below, but it
    just will not work. Any advice?

    Hi Dan,
    Thanks for you help again.
    Assuming the syntax in the attached code is correct, I have
    done the following:
    1. Clear application structure to start from fresh using
    <cfscript>structClear(application);</cfscript>
    2. Commented the toggle code in onRequestStart() from
    Application.cfc
    3. In index.cfm, I uncommented the setting of the three
    application variables commented out in the attached code.
    I then previewed the page and it outputs the value set for
    application.messageA as expected.
    4. Uncommented the toggle code in onRequestStart() from
    Application.cfc
    5. In index.cfm, removed the code that set the 3 variables
    and kept the output code. Refreshing the page once changes the
    output from the messageA value to the messageB value, but each
    subsequent refresh does not change the value.
    This is so frustrating. It should work, unless my syntax is
    wrong?

  • Application variable erroring in function

    All,
    Have a hopefully simple question..why am I getting an  error when I try to reference an Application variable within a method?  Is there a trick to get the method to recognize the application variable?
    Exceptions]
    09:11:59.059 - Expression Exception - in  D:\webroot\model.cfc :  line 74
             Element DBADMIN is undefined in APPLICATION.
    Scope Variables
    Application Variables:
    DBADMIN=databasename

    This suggests to me that at the time the exception was raised, application.dbadmin didn't exist, but at some stage between then and when the debugging was rendered, it was created.
    Where's application.dbadmin created?
    Adam

  • Application variable limits?

    I want to use an application variable as a list,but the length of the list could be very long and it's a variable number of entries in the list. 
    The docs say strings can be as large as server memory will allow.  Is there any limit beyond server memory for application variables?
    Thanks!

    I agree with Dan whole-heartedly,  Application variables should be pretty static. but of greater concern: If you are worried about server memory being a problem, would it be better/possible to store your variable in a database?
    On the flipside - "test it" create a big couple gig application variable and see what happens
    -sean

  • Storage capacity of a Application variable?

    Hi All,
    I want to display a common information to all the user.
    The size of the text information(may consists of html content for formatting) may vary each time.
    1) Is storing the information in application variable a better way?
    2) What is the storage capacity of a Application variable?
    3) Cookies storage capacity is 4k and restricts certain characters.Do Application/ Session variable have storage capacity or it restricts any character.
    Regards,
    Maha

    Hello Friend,
    If U are refering about the mem size of implicit Application varible in JSP.
    Then i think U are refering to an Instance related to ServletContext.
    If that is the case it enitrely depens on the webserver you are using.There would few option by which one can fix the cache size but again how to manage that cache space specified between ServletContext,HttpSession,HttpServletRequest and PageContext is entirely dependent upon webserver you are using.....
    U can try referring the link below which is related to SUN-ONE Application server
    http://docs.sun.com/source/816-7150-10/dwdeploy.html
    and as far as restriction is concerned i don't think u would have restriction of storing any unicode charecters..... But i'm not completely sure abt it through.

Maybe you are looking for