Newbie question... I think

hello fellow java developers!
I have a somewhat simple question, I think....
I have a web application that I built in 2 parts.
Part 1: Does some big task that takes lots of server time and acts as a resource
Part 2: Uses the resource created in (Part 1) to achieve a task.
Kind of like an indexer indexing a website, and a search box using the index - something similar to this...
My question is, how can I achieve (Part 1) so that it is something that remains accessible in memory in a jsp page? Is there something I can do on the server when it boots or something? I just don't know where to put it so that it will run once and be available until the server is turned off....
Thanks in advance!

Certainly this is quite possible.
If it is a shared resource accessible to all users, the best place to store it would be in ServletContext/application scope.
So write a servlet that as part of its init() method loads the resource, and stores it into memory:
public void init() throws ServletException{
  Object myInfo = executeBigTaskThatTakesLotsOfServerTime();
  ServletContext application = getServletConfig().getServletContext();
  application.setAttribute("resource", myInfo);
}That will execute the action, and store the into memory accessible by all users of your web application when this Servlet is loaded.
They can get it via <jsp:useBean scope="application"/>, <%= application.getAttribute("resource") %> or using EL ${applicationScope.resource} or even just ${resource}
Next question - how do you make this code run at startup?
In your web.xml - configure the servlet to <load-on-startup>
<servlet>
     <servlet-name>MyResourceLoader</servlet-name>
     <servlet-class>com.my.ResourceLoaderServlet</servlet-class>
     <load-on-startup>1</load-on-startup>
</servlet>You may want to start a seperate thread to do the resource loading, so you can let your server get on with starting up, but thats entirely up to you, and may result in the server being available for requests before your "indexing" service or whatever has finished. Up to you.
Cheers,
evnafets

Similar Messages

  • Newbie question (I think you can answer me)

    Hello.
    I am a newbie about EJB. But I am teacher of a Java course and I have
    introduced EJB to my students. I have said them that EJB is good for big
    applications but, when the application is small, is overkill (I read this in
    several books). But then a student has asked me (I don't know how to
    exppress the sentence in English) "How big has to be the application in
    order to take advantage of EJB?". I mean: EJB is overkill for an application
    with two concurrent users. But, if concurrent users are thousand, it is
    necessary. Where is the limit between two situations? Of course, there is no
    exact limit but it must exist some QUANTITATIVE parameter.
    I had no reply for my student. Good question but no answer. I said that I
    will look for this information.
    I am getting mad looking for this information in Internet. I have seen no
    studies that study such a basic question. Even it has been impossible to
    find "a ballpark estimate". I seen EJB FAQs, pages, books about EJBs, but I
    found nothing. Any information of this kind would help me a lot.
    So, please, can anybody help me?
    Any help would be greatly appreciated.
    Thanks,
    Pau Vic.
    (I sent a former copy of this message to an unrelated thread. This was a
    mistake. Please excuse the inconveniences)

    Thank you, Ji.
    Pau Vic.
    "ji zhang" <[email protected]> escribió en el mensaje
    news:[email protected]...
    >
    Hi Pau.
    How big has to be the application in order to take advantage of EJB?There is no measurement standard for developers to decide the utilizationof EJB
    in their applications. It is clearly unnecessary to develop a nonenterprise application
    for only few ( as you mentioned 2 ) routing users with EJBs.
    The question is more likely why using EJBs. Few major considerationslisted below:
    >
    1) A real production internet application is getting to rely on anapplication
    container ( for example: #1 application server WebLogic ) to handleunderly resources,
    backend works and Object life cycles.
    By using EJBs, EJB container handles the sophisticate backend jobs foryou.
    Developers may only focus on their business logics.
    2) A real production internet application may be also a combination ofsome reusable
    logical components. To reduce the application development hardness,modeled and
    specification oriented plugable components such as EJBs may be used. Thatis also
    why the EJB component vendors exist.
    3) There are concepts of scalability and high availability in realproduction.
    EJB components can be easily deployed to be scaled and load balanced inthe EJB
    containers in a cluster. Fully implemented Weblogic Cluster is a goodexample.
    >
    There may be other advantages of using EJB as well.
    Thanks.
    Ji Zhang
    Developer Relations Engineer
    BEA WebLogic Support
    "Pau Vic" <[email protected]> wrote:
    Hello.
    I am a newbie about EJB. But I am teacher of a Java course and I have
    introduced EJB to my students. I have said them that EJB is good for
    big
    applications but, when the application is small, is overkill (I read
    this in
    several books). But then a student has asked me (I don't know how to
    exppress the sentence in English) "How big has to be the application
    in
    order to take advantage of EJB?". I mean: EJB is overkill for an
    application
    with two concurrent users. But, if concurrent users are thousand, it
    is
    necessary. Where is the limit between two situations? Of course, there
    is no
    exact limit but it must exist some QUANTITATIVE parameter.
    I had no reply for my student. Good question but no answer. I said that
    I
    will look for this information.
    I am getting mad looking for this information in Internet. I have seen
    no
    studies that study such a basic question. Even it has been impossible
    to
    find "a ballpark estimate". I seen EJB FAQs, pages, books about EJBs,
    but I
    found nothing. Any information of this kind would help me a lot.
    So, please, can anybody help me?
    Any help would be greatly appreciated.
    Thanks,
    Pau Vic.
    (I sent a former copy of this message to an unrelated thread. This was
    a
    mistake. Please excuse the inconveniences)

  • Unix version of Netweaver Dev Studio, Newbie question

    Hi,
    I have a very silly newbie question.  Is there a unix version of netweaver developer studio and if so what is the path to the executable?
    Thanks in advance
    John

    I don't think so.  NWDS is built on top of Eclipse which is an open source project by IBM.   Check out there site.
    http://www.eclipse.org/
    As of right now,  I don't believe that SAP is offering a Unix version and I doubt that they will.
    Regards,
    Rich Heilman

  • SG200-08 Newbie Questions

    I have recently purchased the SG200-08 Smart Switch, but I have a few "newbie questions" about it as I get started using it.
    The on board firmware shows 1.0.1.0. Is that the latest firmware to the switch?
    Do I need to enable IPv6 Auto Configuration and DCHPv6 in my switch settings to be ready for IPv6 as my ISP rolls it out down the road?
    How do I go about changing the switch's username? I was able to easily change the password, but having issues getting the username to change.
    Do I need to do anything about the LLDP-MED settings? What exactly is that?
    How do I confugure the System Time Settings so the switch functions in my time zone (USA Central Time)?
    Thanks a bunch for any assistance!

    Hi Nathan,
    My guess is that NAT is already on - you have one public IP address from your ISP. Your router will use NAT (network address translation) to allow multiple clients (and either dynamically assign them private IPs via dhcp or you set them statically) to connect to the internet using the one public IP. It also sounds like your RV042G is assigning both ipv6 and ipv4 addresses, and theres nothing wrong with that. Unless you have specific information re: ipv6 from your isp, however, I would suggest not worrying about it until you hear from them. Are your macs connected to the router via the SG200 switch? If so, it looks like its passing ipv6 just fine.  UPnP is something completely different - thats with opening ports like you mentioned - its a way that your devices can communicate with the router to automatically enable the proper port forwarding for the device/application.
    Regarding the username, create a new user account. I don't think you can edit the cisco user, but try deleting it after creating and testing a new user account..
    I'm not familiar with the Polycom system, but I would leave the settings as default unless you are using true IP phones (rather than an ATA adapter). From a quick google of the polycom device, I don't think you will gain anything from LLDP/CDP as the handsets use regular cordless phone freqs. With my setup, we use cisco IP desk phones and cordless wifi phones, CDP makes life easy as the cisco access point, wifi phones, cisco switch, and cisco desk phones (connected via ethernet) see each other and know what they're dealing with automatically.
    I don't see the SNTP setting for unicast / broadcast that you're looking at. For the switch to get the time from a sntp server, under administration -> time -> sntp settings, add a server, and then back on time-> system time, enable sntp server as the main clock source. What are you using as your sntp source? Do you have an internal sntp server? You don't need to enable dhcp on the sntp server.
    May I also point you to the two manuals, I think they may be helpful:  RV042G  & SG200
    Hope thats helpful.
    Best,
    David
    Please rate any helpful posts.

  • InDesign or Acrobat (newbie question)

    Hi,
    I tried posting this in the LiveCycle Designer forum, but I think it's a bit too much of a newbie question:
    Once in a blue moon when I'm at work, someone will ask me if I can add text fields to a PDF form so that they can easily type onto it and print it out. I've always done that directly in Acrobat (on the few occasions that it's been requested from me). But I was curious about Adobe LiveCycle since it came with CS3, so I played around with it a couple of days ago. I added the text fields in LiveCycle this time, and it seems to have worked fine. Which is the better program for this kind of task? I'm not 100% clear on the *main* purposes of either program or how they compare. If anyone wanted to give me a clue about it, I'd appreciate it!
    Thanks,
    Phyllis

    > I thought perhaps you could add that capability
    You can (I said I was oversimplifying). However there are contractual
    limits - to oversimplify (!) 500 users per form.
    >Which would be preferable -- receiving form data from LiveCycle or Acrobat?
    It depends what you want to do.
    >
    >I wish I knew what the difference was between these two programs. Is it purely a matter of emphasis on one task or another?
    They come to the same problem in different ways. For a simple task
    they may seem pretty much the same. Some differences:
    * A form made in Acrobat is a PDF with form fields stuck on top; it
    remains a normal PDF in every other way. Forms are almost always made
    by preparing an existing PDF, then adding form fields.
    * A form made in Designer is barely a PDF. It's a wrapper round an XML
    file. You can no longer edit it in Acrobat, ever, even for the most
    simple things. PDF files are imported and converted (sometimes with
    loss of quality or features), or forms are made from scratch.
    * Acrobat form fields are fixed size.
    * Designer form layout can be dynamic.
    Aandi Inston

  • 2 newbies question about diskgroups

    Hi gurus,
    I have 2 newbies question:
    Im working in a RAC Database (11.2.0.3) on Redhat 5.3 with some disk groups. One of this groups have 6 disks on it with different space (134, 236G, 236G, 185G, 185G and 185G).
    My questions are:
    1) What would be happend when the lower space disk will be full?
    2) At this moment the diskgroups are at 45% so i was thinking to change their spaces to have all with the same space (around 193G each), it would create any problem? i should restart database or can do it with database up?
    Thanks

    if a disk is filled, what would happen? could i resize the disks with same size without stop database and without affecting the data stored within each disc?
    By the word 'disk' I assume you mean LUN . When a LUN in a disk group is filled, ASM will use the remaining LUNs to store the data. You should always use LUNs of uniform size to avoid uneven I/O .
    could i resize the disks with same size without stop database and without affecting the data stored within each disc
    You can get the Unix/Storage team to allocate more LUNs for this Server. Once these LUNs are added , check if the following pre-reqs are met for the LUN which is yet to be added to the disk group
    v$asm_disk.HEADER_STATUS = 'CANDIDATE'
    v$asm_disk.PATH = /dev/rdsk/youLUNname
    v$asm_disk.NAME will be NULL
    Now you can add the LUNs using
    alter diskgroup DATA_DG01 add disk '/dev/rdsk/youLUNname' rebalance power 4 ; wait for rebalance to finish (check status in V$ASM_OPERATION)
    Yes. The above can be done without stopping the DB. It won't affect the stored data either.

  • Starting fluxbox-newbie question

    :? I currently have kde running on my system. I installed fluxbox using pacman. 
         How do I start fluxbox? I couldn't even find it, so I su to root, type fluxbox, and get
         an error message saying that another window system is already running! (kde)
        A  typical newbie question, but I don't know how to start fluxbox. I think I want to
        replace kde with fluxbox, so should I just uninstall kde?? 
                                                           Thanks -- Larry

    lmellen wrote:
    :?  scottro -- This is .xinitrc.
    #!/bin/sh
    # ~/.xinitrc
    # Executed by startx (run your window manager from here)
    exec wmaker
    # exec startkde
    # exec icewm
    # exec blackbox
    exec fluxbox
    The only thing I uncommented was" exec fluxbox". I'm still getting kde at start up.
    I have kdm listed in a start up daemon in rc.conf. is this the problem?
                         thanks for the reply -- Larry
    if you comment out exec wmaker and then put a ! in front of the kdm daemon you should boot to a console at which point you login then type startx. you may also have to change your init level but i dunno i haven't used a graphical login manager for a very long time.

  • Trouble backing up Macbook (10.4.11) and some newbie questions...

    I am using a MacBook OS X 10.4.11 and do not have Time Machine. I have a couple newbie questions...
    What is the best way to back up everything? I am using Disk Utility's Restore tab but it is taking forever. I first tried to do it though Disk Utility's First Aid tab but it wouldn't let me make a New Image because the "source was in use", I think it is because I don't have the Install Disc to begin with (http://support.apple.com/kb/ht1553).
    Secondly, does this include everything in "Home" (bookmarks, iPhoto library, iTunes library and so forth), Documents, and Desktop? Or must these be archived and transferred to the external hard drive separately from Macintosh HD?
    Thanks in advance for any help!

    I tried restarting the phone and switching to another USB cable and now it is working so never mind.

  • Airline Travel- newbie question

    New to the iPod scene. Just wondering if there is any harm in allowing an iPod to go through airport security check (ie. x-ray) in my carry-on, or should it be removed and hand inspected?
    Like I said, newbie question.

    I know that the x ray machine won't damage my ipod Classic but am wondering about the tests that security staff sometimes do on electronic items. A few years ago, going through Stansted, security did what we think was a random check on a G3 ibook. The test involved the man wiping a cloth over the ibook which was testing for explosives. We then had to turn the ibook on and let it power up and then shut it down. I did ask if there was any chance that we could lose anything on it and was told no. I'm thinking that the hardware in ipods might be more sensitive and so am asking if there's ANY chance that the same or similar test/s that were done on our ibook could do anything to my ipod classic. We're going to Portugal in a few weeks going through Dublin on way out and returning from Faro.

  • [SOLVED] cool'n'quiet & modprobe newbie question

    This is probably very newbie question, but I have no idea what to do.
    I want to have cool'n'quiet working on my amd64. I turned it on in bios, and downloaded powernowd.
    When I type:
    > modprobe powernow-k8
    > powernowd
    it works. I added powernowd to demons in my /etc/rc.conf but after restarting computer it doesn't work - I have to type both commands above again.
    How to make my system not forget loaded module after restart?
    Last edited by senjin (2007-08-24 19:49:31)

    Use either /etc/modprobe.conf or the MODULES= array in /etc/rc.conf. I would have thought powersaved provided a config file from where you could pick a module to load though... sure there isn't one in /etc/ ?
    Personally i would opt for powersaved, since i think it's more full featured (it's more a _power_ than a _cpu_ manager), but then again you may not care for anything other than controlling the cpu stepping/speed.

  • Total Newbie Question ... Sorry :-(

    I know it's a windows thing, and I am now converted to Mac but I gotta know this because it's doing my head in. It's a complete stupid green gilled newbie question.
    When installing new programs on a Mac can you create shortcuts to the programs on the Dock? I did what I THOUGHT it would be, i.e I made an Alias and stuck it in the dock, but on rebooting my Mac later on, in place of the shortcuts where 3 question marks which when clicked on did absolutely nothing???
    Help?
    A.L.I
    Windows XP Pro Desktop, Macbook Pro, 60GB iPod Video   Mac OS X (10.4.5)   OS X

    You aren't installing something from a dmg file are you? The dmg is a disk image – kind of a virtual CD. So when you double click the dmg and then get the little disk/hardrive/custom icon on your desktop that is the same as if you had mounted a CD. You then need to drag the application off of that "CD" into your application folder. Then it is truly installed.
    You can then "eject" the icon your your desktop. This is what happens when you shutdown and without remounting the image your dock shortcut can't find the original.
    Just a thought.

  • Newbie Question. just installed IE7.. how do I set up a local host to preview sites?

    Sorry for the newbie question... but it's been a long time since I have done this
    Thanks!

    Just define your site in DW as always.  For a static site, that's all you need to do.

  • Newbie Question about FM 8 and Acrobat Pro 9

    Hello:
    I have some dcouments that I've written in FM v8.0p277. I print them to PDF so that I can have a copy to include on a CD and I also print some hard copies.
    My newbie question is whether there is a way to create a  PDF for hard copy where I mainitain the colors in photos and figures but that the text that is hyperlinked doesn't appear as blue. I want to keep the links live within the soft copy. Is there something I can change within Frame or with Acrobat?
    TIA,
    Kimberly

    Kimberly,
    How comes the text is blue in the first place? I guess the cross-reference formats use some character format which makes them blue? There are many options:
    Temporarily change the color definition for the color used in the cross-reference format to black.
    Temporarily change the character format to not use that color.
    Temporarily change the cross-reference definition to not used that character format.
    Whichever method you choose, I would create a separate document with the changed format setting and import those format into your book, create the PDF and then import the same format from the official template.
    - Michael

  • Domain name settings - Newbie question

    Sorry for a newbie question!
    I am already pointing a domain name to web hosting for email account. Now, I need an application server to run ERP software and Oracle, and installing Solaris and Oracle need a domain name.
    If I point my domain name to the server, how do I receive emails from web hosting???
    Install an email server to the application server instead? What can I do if I want the same domain name? Any option?

    Setting up a mailserver and making sure it doesn't suddenly turn into a spambox is not something you do with the use of a few commands. I suggest to dive into the Solaris admin guide on docs.sun.com and read up on e-mail and network services.
    If that is asking too much of your time you'll be better off getting your ISP to handle all this for you.

  • Domain Name settings in Solaris - Newbie question

    Sorry for a newbie question!
    I am already pointing a domain name to web hosting for email account. Now, I need an application server to run ERP software and Oracle, and installing Solaris and Oracle need a domain name.
    If I point my domain name to the server, how do I receive emails from web hosting???
    Install an email server to the application server instead? What can I do if I want the same domain name?

    Your questions are completely off-topic for the forum.
    These SunOS forums are for questions on <i>"how do I install my OS"</i>
    You particular question is in the <i>"how can I install Solaris while using the CD drive"</i> forum.
    So, if you had a question on how to edit the /etc/inet/hosts file to establish a FQDN on the computer, then it might be appropriate for the forum.
    Unfortunately, I don't have a clue on where to redirect you, except perhaps to the Sun Java Enterprise System suite of applications?

Maybe you are looking for