Storing Vector Application Scope - Pressed for time

I'm reading in a file through my application and right now every time a user goes to the page, the file is being read in and parsed etc etc to be formatted for display. Now, I know this can hamper performance dramatically as the users increase, and I want to be able to make this task work optimally.
The file is also being updated through FTP every 15 minutes, and I want to be able to have the correct version read in when a user accesses the page. My first question is whether this is a good way of going about getting and presenting the information?
Secondly, I want to somehow store the Vector of lines from the file globally so that all the users can use it. I want to store the Vector, and a timestamp consisting of the file's last modification date in order to do a check of whether to access the current Vector, or read in the file again and refresh the timestamp all across the application (so the one user to be reading the file during the time that a new file comes in will update it for all other users). What's the best way to go about doing this?
*** Also - If you are familiar with tags, I'd like to know how I can add this functionality to my current tags (one which reads the file, and the other which displays the Vector of lines). I'm not sure how to have the tag just read in session attributes, or just variables that reside on the page.
I really really appreciate your time and help in this matter,
Thank you,
Lior

Caches for all the users. Unfortunately since the code is proprietary, I cannot send you the actual code. But here are the steps to do it:
in web.xml do this:
1.
<servlet>
<servlet-name>ReadfileServlet</servlet-name>
<servlet-class>somepackage.BootstrapServlet</servlet-class>
<init-param>
<param-name>FilePath</param-name>
<param-value>c:\filetoread</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
2.
Create a Global class (say GlobalVariables) which has a member variable (say m_FileContent) and static synchronized set/get methods for the member variable.
3.
In ReadFileServlet's init method,
Read the file specified in FilePath. Then assign it to a servlet member variable (why do you neeed a vector? why not a String?)
Then assign this member variable to the Global class's member variable using the set method (GlobalVariables.setVariable(variable)).
4.
From any jsp use variable = GlobalVariables.getVariable().
Hope this helps.
-Srini

Similar Messages

  • Accessing Application Scope from an EJB

    I'm not sure of the best way of doing this:
    The set up:
    We have a rather large J2EE application that is composed of only servlets and JSPs at the moment (When the application began development EJB was in its infancy and not feasible for the development of the app). Some of the new deployments of the app involve distributed webserver over 4 JVMs and 2 machines. When a user connects the servers load balancing decides which particular JVM they should be connected to. We perform large data caching into the servlet application scope to avoid having to access the database every time a change is made by a user to certain tables in our database. The data caches are stored in hashtables in the servlet application scope.We seem to have no way to determine what other JVMs are running or which JVM a user is currently connected to.
    The problem:
    Apparently the application scope is for a particular JVM. This means that when a user makes a change to a data cache the change doesn't effect users in the other 3 JVMs of the application, only the users who, due to load balancing, happened to be connected to the same JVM as the one where the change was made.
    Our possible solution:
    We were thinking that we could set up a queue (such as MQSeries from IBM) and any time a change is made to one of these data caches put a message on the stack saying that the particular table had been updated. Then a MDB would be listening asynchronously and digest the message from the Queue and recache the tables from the database.
    So here are my questions:
    1. Would this work? Would putting a MDB in the EJB Container give each JVM the MDB in the first place, or would this mean it would pick one of the JVMs to deploy the MDB on and still not fix our problem.
    2. If this does work, how do I access the hashtables stored in the Servlet Application scope from the MDB. I can't seem to find any method available to the MDB (or any EJBs for that matter) that can access the servlets Application scope.
    3. Is this the best way to do this? Or is there a better way to share data between seperate JVMs that I don't have a URL to (It's all ambiguous and handled by the server as to which JVM actually gets the connection.)
    Just in case this is needed:
    We are running IBM WebSphere 5 Application Server and the database could be anything from DB2 to Oracle.
    Thanks in advance for any possible help.

    You wont get any api for directly accessing Servlet application objects from any ejb. I dont think MDB either solves your problem directly. Indirectly you can place a request to some servlet (should be there for each JVM and web application ) and update your application scope variable. I would suggest you to cache the data in database if the size of cache is large. otherwise any open caching tools may help you.

  • Slow starup of Java application - best practices for fine tuning JVM?

    We are having problems with a java application, which takes a long time to startup.
    In order to understand our question we better start with some background info. You will find the question(s) after that.
    Background:
    The setup is as follows:
    In a client-server solution we have a win xp, fat client running java 1.6.0.18.
    (Sun JRE). The fat client containt a lot of GUI, and connects to a server for DB access. Client machines are typical 1 to 3 years old (there are problems even on brand new machines). They have the client version of JRE - standard edition installed (Java SE 6 update 10 or better) Pretty much usual stuff so far.
    We have done a lot of profiling on the client code, and yes we have found parts of our own Java code that needs improving. we are all over this. Server side seems ok with good response times. So far, we havent found anything about shaky net connections or endless loops in the java client code or similiar.
    Still, things are not good. Starting the application takes a long time. too long.
    There are many complicating factors, but here is what we think we have observed:
    There is a problem with cold vs. varm starts of the application. Apparently, after a reboot of the client PC - things are really, really bad - and it takes (sometimes) up to 30-40 secs to start the application (until we arrive at the start GUI in our app).
    If we run our application, close it down, and then restart
    without rebooting, things are a lot better. It then usually takes
    something like 15 - 20 sec. which is "acceptable". Not good, but acceptable,
    Any ideas why?
    I have googled it, and some links seems to suggest that the reason could be disk cache. Where vital jar are already in disk cache on th warm start? Does that make any sense? Virus scanners presumable runs in both cases.
    People still think that 15 - 20 sec in start up on the warm start is an awful long time, even though there is a lot, a lot, of functionality in the application.
    We got a suggestion to use IBMs JRE - as it can do some tricks (not sure what) our SUN JRE cant do concerning the warm and cold start problem. But thats is not an option for us. And noone has come up with any really good suggestions with the SUN JRE so far?
    On the Java Quick Starter (JQS) -
    improves initial startup time for most java applets and applications.
    Which might be helpful? People on the internet seem more interested
    in uninstalling the thing than actually installing it though?
    And it seems very proprietary, where we cant give our Jar files to it?
    We could obviously try to "hide" the problem in some way and make it "seem" quicker. Where perceived performance can be just as good as actual performance. But it does seem a bad solution. So for the cold start we will probably try reading the jar files and thereby have them in disk cache before startup of our application. And see if that helps us.
    Still, ok the cold start is the real killer, but warm start isn't exactly wonderfull either.
    People have suggested that we read more on the JVM and performance.
    java.sun.com.javase/technologies/performance.jsp
    java.sun.com.docs/hotspot/gc5.0/gc_tuning_5.html
    the use of JVM flags "-Xms" "-Xmx" etc etc.
    And here comes the question .. da da ...
    Concerning various suggested reading material.
    it is very much appreciated - but we will like to ask people here - if it is possibe to get more specific pointers. to where the gold might be buried.
    I.e. in a an ideal world we would have time to read and understand all of these documents in depth. However, in this less than ideal world we are also doing a lot of very timeconsuming profiling in our own java code.
    E.g. java garbage collection is is a huge subject - and JVm settings also. Sure, in the end we will probably have to do this all very thoroughly. But for now we are hoping for some heuristics on what other people are doing when facing a problem like ours..?
    Young generation, large memory pages, garbage collection threads ect. all sounds interesting - but what would you start with?
    If you don't have info to decide - what kind of profiling would you be running and then adjust what JVM setting in your trials?
    In this pressed for time scenario. Ignorance is not bliss. But makes it hard to pinpoint the or those JVM parameters to adjust. So some good pointers from experienced JVM "configurators" will be much appreciated!
    Actually, If we can establish that finetuning of these parameters is a good idea, it will certainly also be much easier to allocate the time for doing so. - reading, experimenting etc. in our project.
    So, All in all , what kinds of performance improvements can we hope for? 5 out of 20 secs on the warm start? Or is it 10 % nitpicking? Whats the ball park figure for what we can hope to achieve here given our setup? What do you think based on above?
    Maybe someone out there have done some finetuning of JVM parameters in a similiar PC environments like, with similiar fat clients...? Finetuning so and so - gave 5 secs. So start your work with these one-two parameters?
    Something like that - some best practices? Thats what we are hoping for.
    best wishes
    -Simon

    Thanks for helpful answer from both you and kajbj.
    The app doesn't use shared network drives.
    What are you doing between main starts to get executed and the UI is
    displayed?
    Basicly, Calculating what to show in the UI. Accessing server - not so much, there are some reads from a cache, but the profiling doesnt indicate that it should be a problem. Sure, I could shift the startup time to some other slot, but sofar I havent found a place where the end-user wouldnt be annoyed.> Caching of something would seem most obvious. Normal VM stuff >seems unlikely. With profiling i basicly find that ''everything'' takes a lot longer in the cold start scenario. Some of our local java methods are going to be rewritten following our review. But what else can be tuned?You guys dont think the Java Quick Start approach, with more jars in disk cache will give something? And how should that be done/ what does people do?I.e. For the class loader I read something about
    1.Bootstrap class loader
    2.Extensions class loader
    3.System class loader
    and is wondering if this has something to do with the cold start problem?
    The extensions class loader loads the code in the extensions directories (<JAVA_HOME>/lib/ext
    So, we should move app classes to ext? Put them in one jar file? (We have many). Best practice about that?
    Otherwise it seems to me that it must be about finetuning the JVM?
    I imagine that it is a question about:
    1. the right heap size
    2. the right garbage collection scheme
    Googling heap size for XP
    CHE22 writes:
    You are right; -Xms1600M works well, but -Xms1700M bombs
    Thats one best practice or what?
    On garbage collection, there are numerous posts, and much "masters of Java black art" IMHO, And according to profiling GC is not really that much of a problem anyway? Still,
    Based on my description I was hoping for a short reply like "try setting these two parameters on your xp box, it worked for me" ...or something like that. With no takers on that one, I fear people are saying that there is nothing to be gained there?
    we read:
    [ -Xmx3800m -Xms3800m
    Configures a large Java heap to take advantage of the large memory system.
    -Xmn2g
    Configures a large heap for the young generation (which can be collected in parallel), again taking advantage of the large memory system. It helps prevent short lived objects from being prematurely promoted to the old generation, where garbage collection is more expensive.
    Unless you have problems with pauses, try granting as much memory as possible to the virtual machine. The default size (64MB) is often too small.
    Setting -Xms and -Xmx to the same value increases predictability by removing the most important sizing decision from the virtual machine. On the other hand, the virtual machine can't compensate if you make a poor choice.
    The -XX:+AggressiveHeap+ option inspects the machine resources (size of memory and number of processors) and attempts to set various parameters to be optimal for long-running, memory allocation-intensive jobs]
    So is Setting -Xms and -Xmx and -XX:AggressiveHeap
    best practice? What kind of performance improvement should we expect?
    Concerning JIT:
    I read this one
    [the impact of the JIT compiler is obvious on the graph: at startup the time taken is around 500us for the first few values, then quickly drops to 130us, before falling again to 70us, where it stays for 30 minutes,
    for this specific issue, I greatly improved my performances by configuring another VM argument: I set -XX:CompileThreshold=50]
    The size of the cache can be changed with
    -Xmaxjitcodesize
    This sounds like you should do something with JIT args, but reading
    // We disable the JIT during toolkit initialization. This
    // tends to touch lots of classes that aren't needed again
    // later and therefore JITing is counter-productiive.
    java.lang.Compiler.disable();
    However, finding
    the sweet spots for compilation thresholds has been tricky, so we're
    still experimenting with the recompilation policy. Work on it
    continues.
    sounds like there is no such straigth forward path, it all depends...
    Ok, its good, when
    [Small methods that can be more easily analyzed, optimized, and inlined where necessary (and not inlined where not necessary). Clearly delineated uses of data so that usage patterns and lifetimes are apparent. ]
    but when I read this:
    [The virtual machine is responsible for byte code execution, storage allocation, thread synchronization, etc. Running with the virtual machine are native code libraries that handle input and output through the operating system, especially graphics operations through the window system. Programs that spend significant portions of their time in those native code libraries will not see their performance on HotSpot improved as much as programs that spend most of their time executing byte codes.]
    I have the feeling that we might not able to improve performance that way?
    Any comments?
    otherwise i was wondering about
    -XX:CompileThreshold=50 -Xmaxjitcodesize (large, how large?)
    Somehow, we still feel that someone out there should have experienced similiar problems? But obviously there is no guarantee that the someone should surf by here!
    In c++ we used to just write everything ourselves. Here it does seem to be a question about the right use of other peoples stuff?
    Where you are kind of hoping for a shortcut, so you dont have to read endless number of documents, but can find a short document that actually addresses your problem ... well.
    -Simon
    Edited by: simoncpm on Mar 15, 2010 3:43 PM
    Edited by: simoncpm on Mar 15, 2010 3:53 PM

  • Best hard drive for time machine

    Hi,
    I use a MBP 2011 i7 and connect it to a 24" Cinema display at my home office and remove each day to take to a client office.
    I have a Lacie Porshce 1tb external drive connected to the back of the Cinema display via one of the USB ports. This is the Time Machine drive. Unfortunately, there are no firewire ports in the back of the display.
    I dont plan to buy a new Thunderbolt display at this stage.
    Often pressed for time in the morning, on the way to my client site, my MBP is in sleep mode and I dont always have time to wake it and then eject the Time Machine. This means the 'failed to eject / you bad person' message or effect takes place.
    When I reconnect the MBP to the Cinema display in the evening, I need to turn off and turn on the external Lacie drive to get it to reconnect to my MBP through the Cinema display. I would really like it to sort itself out as its quite a pain.
    A friend has suggested that some brands of drive may be better at recovering from this situation by itself.
    Does anyone out there have experiences they can share on this subject?
    Regards
    Eric

    Any drive that is NOT properly shut down can eventually corrupt (no guaranteed failure, but ...).
    Constant-speed drives are best, not drives that self-sleep, as a sent datapacket may be kicked back and confuse the application and the OS.
    Take the time to wake the system and properly dismount, my humble opinion.
    Also, I run two external drives.  One TimeMachine, one CarbonCopyClone.  CCC backups are bootable, offering a bootable alternate system in case of disaster.

  • What are the pros and cons of storing heavely used CFCs in the application scope?

    I've been storing all the required CFCs for a site in the application scope. During onApplicationStart I do something like this application.objSomeCfc =CreateObject('component', 'com.someCfc').init().
    Here is my reasoning.
    Get the CFCs initialized once and stored in memory for better performance.
    Using CreateObject several times on each page load can have a negative impact on performance.
    Having one place to create application scoped CFCs makes it easier to manage code.
    So is my thinking flawed? Are there any additional pros or cons for dealing with CFCs? Is there any docs, articles, blogs, videos, frameworks, ...... that I should check that may change my perspective on how I'm doing this?
    Thanks

    Your approach is fine, depending on how many and what type of CFCs you are talking about. If they are "singletons" - that is, only one instance of each CFC is needed to be in memory and can be reused/shared from multiple parts of your application - caching them in the application scope is common.  Just make sure they are thread safe ("var" or local.* all your method variables).
    You might consider taking advantage of a dependency injection framework, such as DI/1 (part of the FW/1 MVC framework), ColdSpring, or WireBox (a module of the ColdBox platform that can be used independently).  They have mechanisms for handling and caching singletons.  Then you wouldn't have to go to the application scope to get your CFC instances.
    -Carl V.

  • Application for time sheet in HR abap

    Hi all,
      please tell me what is the application and output type for time sheet in HR ABAP. and also tell me step by step procedure how to work on HR forms
    Regards,
    Srinivas.

    Hi,
    Regarding Time Sheet Issue....
    To fill in time sheets in SAP . Make use of CATSDB to enter data.
    Goto SE38-->Type CATS* and press f4..you would get the list of the programs..to enter and maintain timesheet data.
    I hope it helps.
    Regards,
    Suruchi

  • Need to develop a Mobile Application for Time Entry

    Hi,
    I need to develop a Mobile App for Time Entry details which can used as an Applicaion on Android or iOS.
    Can anyone help me with the approach i need to follow to develop such an application which can be used on Android or other OS.
    Thanks,
    CV

    Hi CV,
    Oracle Application Development Framework Mobile (ADF Mobile) browser is a standards-based framework that enables the rapid development of enterprise mobile applications. Oracle Fusion Middleware 11g release 1 of ADF Mobile browser extends Oracle ADF to browsers running on mobile devices. Because ADF Mobile browser is built upon the component model of Java Server Faces (JSF), you can quickly develop applications for mobile browsers. ADF Mobile browser's mobile-specific extensions to JSF enable you to develop mobile applications using the same methodologies for developing JSF applications for the desktop.
    http://docs.oracle.com/cd/E17904_01/web.1111/e10140/pda_ovrv.htm#ADFMB101
    Cheers,
    Vlad
    Give points - it is good etiquette to reward an answerer points (5 - helpful; 10 - correct) for their post if they answer your question. If you think this is helpful, please consider giving points

  • My itunes will not open! is giving me error7(windows error 1114) RUNING TIME  ERROR, PROGRAM FILES\ITUNESHELPER.EXE R6034 An application has made an attempt to load the C runtime library incorrectly. I must contact the application support team for imforma

    my itunes will not open! is giving me error7(windows error 1114) RUNING TIME  ERROR, PROGRAM FILES\ITUNESHELPER.EXE R6034 An application has made an attempt to load the C runtime library incorrectly. I must contact the application support team for imformation and  i tried downloading itunes like 10 times and is saying the same thing. Please help! i need to sync my ipads and ipods thank you!

    Follow the instructions of tt2 given in https://discussions.apple.com/thread/5822086

  • Can individuals (students) purchase Adobe CC (one application or all) for just a portion of the year (i.e. a semester - 1 to 4 month span)?  My students would like to purchase the program for a month at a time without making a yearly commitment.

    Can individuals (students) purchase Adobe CC (one application or all) for just a portion of the year (i.e. a semester - 1 to 4 month span)?  My students would like to purchase the program for a month at a time without making a yearly commitment.

    Sure they can, just not for a student discount.
    Mylenium

  • Looking for best practice on application scope beans

    Hey – a portal newbie here. I’ve got some application scope beans that need to be initialized on startup. First thought was to create a servlet that would set the bean. Then I saw the GlobalApp setting, but I think that looks like it is more session scope than application… Looking to be corrected here if I am wrong.
    Is there a place where these type of things traditionally happen? Read only, so no cluster worries (I think) Using WLP 8.1 SP4 and looking for best practices. Thanks for the help!

    To support "code sharing" you need an integrated source code control system. Several options are out there but CVS (https://www.cvshome.org/) is a nice choice, and it's completely free and it runs on Windows, Linux, and most UNIX variants.
    Your next decision is on IDE and application server. These are usually from a single "source". For instance, you can choose Oracle's JDeveloper and Deploy to Oracle Application Server; or go with free NetBeans IDE and Jakarta Tomcat; or IBM's WebSphere and their application server. Selection of IDE and AppServer will likely result in heated debates.

  • Is that a good practice to use syncronize methods for application scope cls

    Is that a good practice to use synchronize method in a application scope class, so I have a doubt, there a is class A, it has application scope and it contains a synchronized method add, so because of some network traffic or any unexpected exception client1 got stuck in the method, will that add method available for any other client...?
    Edited by: navaneeth.j on Dec 17, 2009 4:02 AM
    Edited by: navaneeth.j on Dec 17, 2009 4:04 AM

    If it needs synchronization, then it probably doesn't belong in the application scope. Either keep it as is, or reconsider the scope, or make it static.

  • The error message "No more virtual tiles can be allocated" appears when I try to use the effects in the quick editing mode in my Elements 13. The baton OK has to be pressed several times for loading all effect patterns. The error returns when selecting th

    The error message "No more virtual tiles can be allocated" appears when I try to use the effects in the quick editing mode in my Elements 13. The baton OK has to be pressed several times for loading all effect patterns. The error returns when selecting the particular pattern.
    The problem does not appear, if PH Elements 13 is executed in the administrator mode.
    The available computer resources are rather  large enough: CPU INTEL i7 4 cores,  16GB RAM, 1TB HDD + 32GB SSD, Windows 8.1.
    Please, advice how to solve this problem? Maybe, there is patch or updating available?

    Dear n_pane,
    Thank you for the quick answer. In the meantime I found other way to pass by the problem. I increased the cache level up to the maximum value 8.
    The errors reported as "No more virtual tiles can be allocated" vanish, but I still do not understand, why PSE 13 cannot work properly by the lower cache levels, having available maximum resources it needed (10443 MB RAM and 26.53GB SSD space for scratches), or cannot collaborate with the fast SSDs properly.
    I wish you all the best in the New Year 2015!

  • I have started migration système to transfert from hold Macbook pro to New MacBook air application starter successfully for several hours. But since more than 3 hours I got the message transferring Time zone paramètres with time left less than 1 minute.

    Hi
    I have started migration système to transfert from hold Macbook pro to New MacBook air
    Application starter successfully for several hours.
    But since more than 3 hours I got the message "transferring Time zone paramètres " with time left less than 1 minute.
    Any recommendation or suggestion to solve it ?
    Many tanks

    If it has run for 3 hours it's probably done and you can quit Migration Assistant and reboot the new computer. In the future rather than using Migration Assistant I would recommend using Startup Assistant which tends to be a bit more reliable and does not create a new user account as MA does. If  you're interested here is an article explaining Setup Assistant tips.
    Roger

  • Storing int variable in application scope

    hi all,
    I have a requirement where i need store some counter(int) in the application scope. Please tell me how to do that. I know create instance of userbean in application scope, but how to do for integer. Thanks in advance.
    -Manjunath

    Hi,
    you can only store Java Objects in the various scopes. you cannot store the primitive data types. so convert the integer to Integer Object and then store that one using setAttribute. Dont forget to parse the retrieved object to Integer as you will get Object type.
    do this:
    int i=10; //you have
    Integer j = new Integer( i );
    request.setAttribute("name", j );
    Integer k =(Integer)requst.getAttribute("name");Hopes this will help you.
    Prasad Babu Dandu,
    BOB Technologies,
    Bangalore

  • If I choose a hard drive ask my backup disk for time machine, will it clear out the data that was previously stored in my hard drive?

    If I choose a hard drive ask my backup disk for time machine, will it clear out the data that was previously stored in my hard drive?

    Hello edjhsu,
    Unless the drive is in a format that isn't compatible with Time Machine, the files will not be overrwitten. However it is typically a better idea to keep your files and your backup separate, especially since files on the Time Machine drive will not be backed up by Time Machine.
    Mac Basics: Time Machine backs up your Mac
    http://support.apple.com/kb/HT1427
    Cheers,
    Allen

Maybe you are looking for

  • Attaching VGA video adapter and Firewire device

    I'm using the VGA video adapter to attach my brand new Mac mini to a VGA screen. As the space between video port and Firewire port is too narrow with the VGA video adapter attached I can't connect any Firewire cable! Anyone who knows how to connect V

  • CollapsiblePanel, z-index and css

    Hi all hi have a problem with this link http://www.aubryhijazi.com/assurancex.htm on the left side panel I have a spy CollapsiblePanel. It work fine in IE but not with Safari, Opera or Firework. Thank you for the help

  • I need to run the program in back ground and then update two fields

    hi gurus i need to run the program in back ground and then update two fields in the z table by mm02 transaction by using bapis , can any one give me the code for this. Message was edited by:         Rocky

  • How do I put a band i like on to my alerts?

         I just download the newest ITunes tech.Now i want to put more bands on my alerts.But i can't find the link where i can. I have looked all over the artists page. I was wondering if someone can tell me if they took it off> But I can still look on

  • Stuttering Songs in iTunes

    I have seen a few posts on this subject in the discussions, but no one really had a resolution for it. So, I thought I would try to share my problem, and see if anyone has some resolutions for it: I just purchased a 24" iMac, 2.8ghz intel, 2 gig ram.