The best place to put the global parameter

hello:
i am now studying the petstore1.3,and find that the global parameters are kept in the servlet context,i wonder if it is a good solution.in my project,i seldom use the servlet context,session context etc,i feel more like to put the global parameter in a singleton that is loaded when the app is started. i don't know where is the best place to put the global parameter,servlet context or singleton?

thanks for your answer.
1 do your mean that the singleton can be shared among the different "war"
packages if both of them are within the same jvm?if yes,must they be in the
same "ear" package?
2 if my app is deployed in the weblogic cluster environment,which one can be
shared? singleton or servlet context?

Similar Messages

  • Where is the best place to put custom functions?

    Hi,
    I have a composition which has a number of symbols. I have to call some custom methods externally and was wondering where is the best place to put the custom methods?
    I have seen posts that I should put the code in the CompositionReady event of the stage but I would like to put it a bit closer to the symbol.
    Is this the best place?
    Sham.

    Here is a case:
    It's a good idea if you well understand global and local variables.
    About complete event, you are right.

  • Where is the best place to put cfqueries?

    Where is the best place to put cfqueries, in the <head> </head> or before the html tag? Thanks

    So before the doctype tag? Thanks
    I just doesn't really matter.  the doctype, head, body, etc only matter to the browser; the CF tags only matter to CF.  The browser doesn't see the CFML, and CF doesn't care about the mark-up one bit: it just ignores it.
    The best place - as I said - is not in the same file at all.  But if you insist on slapping your business logic in with your display logic, then the only consideration is that you need to set your variables before you use them.  Other than that: it simply doesn't matter.
    One consideration you might make is - even if it's all thrown into the same one file - at least separate the file itself into sections: have all your CFML code that gets your data at the top, and try to limit the CFML you have mixed in with the mark-up, eg: limit it to stuff like loops and conditionals.
    But, seriously, separate your concerns.  Dan's pretty much just wrong when he said it's over-engineering. It's just sloppy to not to write tidy, well-maintained, well-organised code.
    Adam

  • Best place to put cffunctions?

    Hi All,
    I've created a cffunction which I need to access more or less from every page. Where is the best place to put it?
    Can I put it in the Application.cfc? If yes how, and how can I call it from a page?
    Thanks!

    ianskinner wrote:
    Just realize if you are putting the function into the session scope, each and every user is getting an entire copy of the function in the server's memory.
    Depending on the purpose of the function and how you are using it, this may or may not be a lot of memory used up unnecessarily.
    If the function is something that each user does not need their very own copy then it might make more sense to put it into the application scope.  Then there would be one copy of the function that all users utilize.  You could, of course, do that in the OnApplicaitonStart() function of the Application.cfc.
    I agree with Ian that Dan's advice in this case is suboptimal.
    The only things that should go in the session scope are things that specifically related to the session.  Which is not the case here.
    Adam

  • Where is the best place to put programs to start on X/Openbox startup?

    Hi,
    There are several places to put programs to startup when you start X or a WM.  I'm using Openbox and presently have placed these into my .xinitrc file, but I'm not sure this really the best place.  Openbox has a autostart file, which sorta looks like a better bet.
    Any suggestions would be great.
    Thanks,
    Jon

    Hadn't heard of consolekit; it's not clear to me from looking at their website what it's supposed to be offering? Maybe after it matures more, the documentation will improve, and all will become clear.
    When I used Openbox, I just launched everything such as conky from the Openbox autostart file. I guess if you had a weird set up such as some of your Openbox configs sitting on unmounted partitions, their mount commands would go in .xinitrc, otherwise autostart.sh seems better.
    Just IMO of course, do what you want on your own machine :-)
    Last edited by /dev/zero (2011-10-27 21:04:37)

  • 2 HD laptop setup - Best place to put Catalog, Cache, and Images??

    If I have two 500GB 7200rpm hard drives in my MBP, what is the best place for LR3, the catalog/previews, ACRcache, and the image files themselves?
    SATA3 connection for both HDs
    Should the boot drive hold the app and cache, while the second drive hold the files and catalog?
    Should the catalog and cache always stay on the same drive?
    Does it matter at all where the image (raw) files sit?
    Thanks!!

    I'd just keep the images on a different drive with a 2 internal drive setup.

  • Where is the best place to put music for itunes

    I have just downloaded Itunes
    I have a lot of music I want to add to the Itunes Program
    Where do I store the music I have in the Windows 7 there is a folder called music
    do I place all the folders into this (Music Folder)
    and then have Itunes find the music folder and add them into the program
    Is the best way to do it.
    Over time I will add more songs do I just keep placing them into the music folder and have Itunes fiund the new songs and add?
    I need your assistance
    THanks
    Mike

    iTunes will not find files, you need to add them to your library.
    launch iTunes, go preferences > advanced and verify the copy files ... when adding and keep ... organized options are checkmarked.
    next, look inside the iTunes folder for a subfolder called automatically add to iTunes. drop your music files in there. when iTunes has finished adding the files to your library, you may delete the original files.

  • Best place to put the event listener?

    Hey there!
    I am loading several images using a loop. My question is, would it be better to put the "contentLoaderInfo.addEventListener(Event.COMPLETE..." in the loop so it loads the compelte handler each time it goes through the loop, or is it fine to put it outside of the loop at the end?
    Also, could you explain the reason for your answer?
    Thanks!

    alright. here is what I have:
              public function placePictures():void {
                   private var imageURLs:Array = ["images/1.jpg","images/2.jpg","images/3.jpg","images/4.jpg",
                                         "images/5.jpg", "images/6.jpg","images/7.jpg", "images/8.jpg",
                                         "images/9.jpg"];               
                   var ba:Array = new Array();
                   ba.push(b1,b2,b3,b4,b5,b6,b7,b8,b9);
                   for(var i:uint=0;i<ba.length;i++) {
                        trace(name + ba[i]);
                        ba[i].name = i;
                        imageLoader = new Loader();
                        imageLoader.load(new URLRequest(imageURLs.shift()));
                        //HERE...///////////////////////////////////////////////////////
                        //imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadCompleteHandler);
                        imageHolder = new Sprite();
                        imageHolder.graphics.lineStyle(5, 0x000000, 100, false, LineScaleMode.NORMAL, CapsStyle.NONE, JointStyle.MITER);
                        imageHolder.graphics.drawRect(0, 0, 180, 100);
                        imageHolder.addChild(imageLoader);
                        if (i<=2){
                             imageHolder.x = 250 + i * 300;
                             imageHolder.y = 0;
                        } else if (i<6) {
                             imageHolder.x = 250 - 900 + i * 300;
                             imageHolder.y = 200;
                        } else {
                             imageHolder.x = 250 - 1800 + i * 300;
                             imageHolder.y = 400;
                        ba[i].y = 230;
                        ba[i].x = 0;
                        ba[i].buttonMode=true;
                        ba[i].addChild(imageHolder);
                        peHolder.addChild(ba[i]);
                        ba[i].addEventListener(MouseEvent.CLICK, onButtonClick);
                   //OR HERE...//////////////////////////////////////////////////////////////
                   imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadCompleteHandler);
              public function loadCompleteHandler(e:Event) {
                   trace ("load complete handler loaded");
                   imageLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, loadCompleteHandler);

  • Best place to put validation code?

    Hey,
    When using jsp and html forms for passing information from the
    client to the server, where should i put the validation code? Is
    it better to put the code in the bjc4 classes or to make some
    FormHandler.jsp which checks wheter correct values/types typed
    in the form by the user?
    If i put the code in the bc4j classes, how can i then interact
    with user, when he makes an error?
    thx

    The question is the classic stand off between resuablity and
    modularity and user interface.
    If you put the validation code in the client (jsp) then the user
    sees the error quickly and it is relatively painless. However,
    if the rules change, you must change ALL of the clients that
    enforce that rule.
    If you put it in the middle-tier then there is the delay in the
    user feedback. The middle-tier will only validate the code on
    some sort of post. However, your validation code will be in only
    one place and therefore easy to maintain over time.
    So what's the solution. I suggest for JSPs a combination. If the
    rule is a real business rule then it needs to be validated in
    the middle-tier. If it is something that is prone to user typing
    error and is simple enough to be enforced within html, then it
    should go there also. You must remember that those client based
    rules can spread and your maintenance effort will go up.
    Gary
    JDev Team

  • Best place to put shared folders

    Switching from pc to mac. In windows you have a "shared folders" folder for all accounts and under each account a public shared folder. Where would I put the "shared folders" folder? at the HD root?

    I usually recommend the bootdrive -> Users ->Shared folder.

  • Best place to put startup code in EJB deployment?

    Hi,
    I'm working on an application which involves timer services and JMX, and I'd like to ask for your opinion on how to deal with startup of those services in an EJB deployment. If you dealt with those issues before, I'd appreciate it if you could share your experiences/best practices on the subject.
    Timer services need to be started, and MBeans need to be registered with the MBeanServer, so I'd like to see how can this be done upon application deployment.
    I'm using Sun Server as an EJB server.
    Thanks,
    Mark

    Since the ejb spec doesn't define an application initialization event, the only portable way of doing this that I've heard of is to use the ServletContextListener.contextInitialized() event to send a message to an MDB within the same application. Since EJB Timers are persistent and their identity is tied to a particular application component, the MDB's onMessage method can use getTimers() to see whether the timer already exists. If not, it's the first time the application has been deployed.
    I agree the auto-creation of timers upon deployment would be a good addition to the spec :-)
    --ken                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Best place for the sub.

    Hi,
    I have a 2.1 speaker system (I-trigue 3400) and was wondering if anybody knows the best place to put the sub so you can hear the deep bass more, it is infront of my legs now, and when i bend down i can hear more, but when i put it above my head i cant hear it again.

    To find the best place for a sub is quite complicated. The distance from walls, corners and other objects makes a huge difference. One way is to place the sub where you will be sitting; put it as close to where your head will be as you can. Then play some music with nice deep bass and crawl around the floor. You should notice that there are areas where the bass is louder, these are the best spots to place the sub.

  • The better place to put EJB Initialization code

    I have some stateless session beans that need to be initialied from a few sources
    to set
    some internal variabes. Where would be the best place to put this code.
    In the ejbCreate , in a default constructor, or in the setSessionContext method.
    Thanks.

    Thanks.
    Rob Woollen <[email protected]> wrote:
    They're all roughly equivalent.
    When the container wants to create a new slsb instance, it will call
    the
    ctor, setSessionContext, and ejbCreate in that order.
    FWIW, setting initial-beans-in-free-pool to > 0 will instruct the
    container to precreate instances if you're looking to do that as well.
    -- Rob
    Tim Bounds wrote:
    I have some stateless session beans that need to be initialied froma few sources
    to set
    some internal variabes. Where would be the best place to put thiscode.
    In the ejbCreate , in a default constructor, or in the setSessionContextmethod.
    Thanks.

  • Best place for images outside of MS Store App?

    Newbie question? If multiple Apps share many images, where is the best place to keep them? 
    There will be hundreds of images in each App - some of them duplicate between Apps. I do not want to house them in the Images folder of the C# source code because they may change as time goes on. I would like to locate them "outside" the App and
    retrieve them when necessary if possible.
    I tried parking them in a website and accessing them this way: 
    ImagePath="http://mywebsite.com/Cookbooks/Receipts/English/Pages/Receipt1.1.1.png". But Go Daddy says I cannot house them that way for a MS store App. 
    So, where is the *best* place to put these images? Website, Web server, OneDrive, Azure, etc. Any other directions for building a scalable and flexible App would be appreciated. Thanks. 
    FS

    Hi,
    I think that's depend on your scenario.
    you could also use Windows Azure Mobile Services. There's a good Todo app sample on the following site -
    http://www.windowsazure.com/en-us/develop/mobile/tutorials/get-started/
    Or you can use web service, we can use httpClient to communicate with it.
    Please follow this document
    http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh761504.aspx
    Best Wishes!
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. <br/> Click <a
    href="http://support.microsoft.com/common/survey.aspx?showpage=1&scid=sw%3Ben%3B3559&theme=tech"> HERE</a> to participate the survey.

  • Right place to put diadem express

    Hi.  I'm trying to find out the best place to put my diadem express so that it will open after the completion of the program.  When you click the log button, it saves data and after you click the log button again the data collection stops.  I would like for diadem to open after this and in the report fill in with the data saved.  However I don't know where in my loop structure I should place this.  The Project with all the sub vi's are included.
    Attachments:
    PressureAmpDaq.llb ‏241 KB

    Hi ChooChoo,
    You have quite a few options of how you could architect your program. What makes the most sense to me is to use a State Machine. There are several state machine examples that ship with LabVIEW and even more can be found at ni.com/community. You can also start from one of the State Machine templates when you create your project, so that it's easier to get started.
    Here is a helpful White Paper: http://www.ni.com/white-paper/7595/en/
    I'd recommend changing the front panel a bit so that when the "Log" button is pushed, you continuously collect data until a different "Stop/End Log" button is pushed. This "Stop/End Log" button does not stop your whole program, but rather tells the state machine to go to the state where you are logging data to the DIAdem report. 
    Another idea you might want to look into is to use TestStand. TestStand is test sequence framework specifically made for testing mutliple units from the same program in a very efficient manner. 
    More info on TestStand: http://www.ni.com/teststand/
    Kelsey W.
    National Instruments
    Applications Engineer

Maybe you are looking for