I want to use static variable instead of using variable in servlet context

Hi all,
In my web application i have to generate a unique Id.
For this, At the application startup time i am connecting to the database and getting the Id and placing it in the servlet context.
Every time i am incrementing this id to generate a unique id.
But, now i want to place this id in a static variable which is available to all the classes.
why i want to do this is to reduce burden on servlet context.
my questing is, is this a best practice ? If not please give me your valuable suggestion.
thanks
tiru

There isn't a problem with this as long as you want to share the value of that variable with all requests. If this is read-only except when it is first set then you're fine. The only real issue will be how to initialize and/or reinitialize the variable. When the servlet is started, how will you get the value for the variable? If the servlet is shutdown and restarted (a possibility in any application server) how will you re-read the variable? You need to answer these questions to decide the best route. It may be as simple as a static initializer or it may be more complex like a synchronized method that is called to see if the variable is set.

Similar Messages

  • Safari (Mac OS) wants me to install Flash instead of using HTML5

    Hi,
    I re-installed Mac OS from scratch. No Flash player is installed yet, and when I open one of my Captivate files (published as Flash & HTML5) in Safari, I'm redirected to a Flash player download site.
    So,
    - when opening index.html (HTML5 version), everything works fine.
    - when opening project_name.htm (Flash version) I'm redirected to get.adobe.com, which is fine.
    - when opening multiscreen.html, I'm redirected to get.adobe.com as well. That's not finde, I'd like to play the HTML5 content instead.
    Is there anything I can do about this?
    Thanks
    Pidd

     

  • Is there a way to auto suggest text using characters entered instead of using a dropdown?

    I am working with a list of more than 100 entries for part numbers.  Instead of requiring someone to click the down arrow for a list that will scroll off the screen, is there a way for the dropdown list to limit entries shown based on the first few characters
    typed?

    See http://www.contextures.com/xlDataVal10.html
    Regards, Hans Vogelaar (http://www.eileenslounge.com)

  • Facelet to crare web app, instead of using JSP; JSF1.2 spec in WebSphere6.1

    Novice to JSF and Facelet. But, I had been using Struts since its inception.
    I am required to use IBM's WebSphere Application Server 6.1 that comes with Servlet 2.4 and JSP 2.0. WebSphere 6.1 App Server limits me to using JSF 1.1. This is because, JSF 1.2 requires Servlet 2.5 and JSP 2.1, that is a part of WebSphere App Server 7.0; not a part of WebSphere 6.1.
    Somebody suggested that it will be possible to use JSF 1.2 in WebSphere 6.1, if I were using Facelet, instead of JSP.
    I am not eager to use JSF 1.1 and may have to forego JSF; unless and until I can use JSF 1.2.
    The hold-up is that I cannot use JSF 1.2 spec in WebSphere 6.1. Is there is any way to use JSF 1.2 in WebSphere 6.1? Can I create an entire application using Facelet (instead of JSP) that will let me use JSF 1.2 spec in WebSphere 6.1? If so, how?
    Here are my questions, especially because I am not very familiar with JSF and Facelet technology:
    1. Can I use JSF 1.2 specification in WebSphere 6.1, if I were using facelet (as opposed to JSP) as my view technology?
    2. Will it be possible to create an entire web app with facelt, instead o fusing any JSP at all? If so, how? Does it mean that all the GUI screens will only use facelet and no JSP at all?
    3. Please explain how I can write a complex web app with 100s of screens using only facelet, instead of using JSP.
    4. Please provide pointer on how JSF and facelet differ, or what are their demarcations boundaries.
    Any comment and pointer will be greatly appreciated.

    Don't doublepost. It's rude. Stick to one topic. Continue here: [http://forums.sun.com/thread.jspa?threadID=5335001].

  • When to use AMF and when to use RTMP??

    Hello can someone explain the difference??
    I am using all the defaults for the configurations files
    (remoting and datamanagement) and my app works perfectly on
    development mode where everything is on localhost, but when we try
    it on pre-production it keeps throwing an error saying that it
    couldn't connect to the RTMP channel. The only thing that changes
    between these two modes is that on development i access everything
    on localhost and on pre-production we point to another server.
    I am totally clueless why this is happening, i am bit
    confused why data-management uses RTMP and why remoting uses AMF,
    so if anyone could explain it to me it would be great.
    Thanks

    There's no special reason why one uses RTMP vs. AMF. Data
    management service can also use AMF and Remoting can also use RTMP.
    The only real requiement is that Data management service needs to
    be able to receive updates from the FDS/LCDS server. This can be
    achieved by using a channel that is capable of receiving pushed
    updates from the server (eg. RTMP) or a channel that is capable of
    polling for updates on the server (i.e. AMF-polling). Therefore,
    when you use AMF with Data management service, you need to have
    polling enabled with a polling interval.
    In terms of why AMF works but RTMP doesn't is that AMF
    channel uses AMF format over the HTTP protocol whereas RTMP channel
    uses simple TCP socket (and not HTTP). Therefore in some
    environments, RTMP will be blocked by the firewalls but AMF won't
    since it's like regular HTTP traffic. In this case, you can use AMF
    polling instead or use RTMPT which is new in LCDS 2.5.

  • Using Static Variable against Context Attribute for Holding IWDView

    Dear Friends,
    I have a method which is in another DC which has a parameter of the type IWDView. In my view, I will have an action which will call the method in another component by passing the value for the view parameter. Here, I can achieve this in 2 types. One is - I declare a static variable and assign the wdDoModifyView's view as parameter value and I can pass this variable as parameter whenever calling that method or the second way - create an attribute and assign the same wdDoModifyView's view parameter as its value. Whenever I call this method, I can pass this attribute as parameter. What is the difference between these two types of holding the value since I am storing the same value i.e., wdDoModifyView's view parameter. But when I trigger the action from different user sessions, the first type of code (using static variable) prints the same value in both the sessions for view.hashCode() and View.toString(), but the same is printing the different values when I pass the attribute which holds the view parameter.
    Clarification on this is highly appreciated
    The problem I face is when I use static variable to get the view instance and export the data using the UI element's id, the data belonging to different user sessions is mixed up where as when I use Context Attribute, the same problem doesn't arise. I want to know the reason why it is so. Is there any other place or way where I can get the current view instance of each session instead of wdDoModifyView?

    Hi Sujai ,
    As you have specified the problem that we face when we use  static attributes, when end users are using the application .
    Static means i  have n number of objects but the static variable value will remain same every where.
    when it is context attribute for every object i.e nth object you have a nth context attribute i mean nth copy of the context attribute.
    so every user has a unique Iview parameter , when context is used and
    when static is used  , assume you have userA , his iview is set this intially  and u have another user B , when he is using  , since the variable is static and when you access this variable you will get the value of userA.
    Regards
    Govardan Raj

  • Can I use static variable in EJB?

    Many books suggest developer don't use static variable in EJB,I want to know why?
    I know there isn't any problem if the static varibale is read only
    For writable static varible ,what will happen if I use a static Hashtable for share data
    Help me!Thank you very much!!

    Greetings,
    I know that "EJB business methods are not allowed to
    block on synchronized resources" Just where do you "know" that from?? The EJB 2.0 Specification, at least, is nowhere in agrement with this statement. If it comes from a book I would question the author's reasoning. Contractually, there's no sound basis for this. In the case of Session Beans, they have an expressedly direct and single-threaded association with a client. From a design viewpoint, it certainly seems unnecessary for a bean to "block" its one-and-only client, but to say that it "is not allowed to" do so is without merit. Entity Beans, on the other hand, are concurrently accessible. Yet, with regard to a transactional context being in effect, the container does indeed block on a bean's business methods. For the bean to do so itself is, therefore, unnecessary. Furthermore, the specification explicitly concedes that a "Bean Provider is typically an application domain expert" and "is not required to be an expert at system-level programming." (EJB 2.0 Spec. 3.1.1) From these statements alone it is reasonable to assume the above statement is meritless since the Bean Provider is not expected to even consider synchronization issues when developing a bean.
    But I'm mixed up why we could use "Hashtable" or otherApparently, because your sources are as well...
    collection classes in the EJB ,in these method many
    methods are synchronized In fact, not only "can we use" them but, with respect to multiple-row finders in Entity Beans we are [i]required to use them (or an iteration of them)! Not all Collection classes are synchronized (so called "heavy-weight collections"). As shown above, that the choice of a particular Collection class might be synchronized is of little consequence since a bean designed under strict adherence to the specification ensures that it is never concurrently writeable.
    Could someone provide a good way for this problem?
    Please Help Me!!!Regards,
    Tony "Vee Schade" Cook

  • When should I use static variable and when should not? Java essential

    When should I use static variable and when should not? Java essential

    Static => same value for all instances of the class.
    Non-static => each instance can have its own value.
    Which you need in which circumstances is completely up to you.

  • Plan changing when using variables instead of constant

    Hi,
    I have a query, when run with the constant values uses a better plan. But when these constants are replaced with variables, plan is changing and taking much longer time to complete. I don't want the query to use a different plan when using the variables in place of constants.
    Please help.
    Thanks

    Probably you got caught by bind variable peeking (if the plans are same for both variables)
    If you have default 10g Statistics gathering job it means you are collecting histograms
    If my bind peeking + histogram assumption is true Check this link to fight with peeking
    http://www.pythian.com/news/867/stabilize-oracle-10gs-bind-peeking-behaviour-by-cutting-histograms
    if deleting histograms doesnt help
    check this link
    http://www.oracloid.com/2006/07/bind-variable-peeking-with-no-histograms/
    A. Coskan GUNDOGAR
    Oracle DBA
    http://coskan.wordpress.com
    ““Knowledge is of no value unless you put it into practice.”.”
    Anton Chekhov

  • I am having trouble with my hotmail emails and want to get rid of them and start to use icloud emails instead.  Is this possible?

    I am having problems with my hotmail and live emails and want to cancel them and use icloud email instead, is this possible and how do I do it by creating icloud emails, and using icloud emails

    See the link below for how to sign up for and set up an iCloud account, including an @icloud.com email address:
    http://www.apple.com/icloud/setup/
    You'll need to update your Mac OS to 10.7.5 or later.

  • Is is better to use static variables?

    Hi,
    Does anyone know if it's better to use static variables or to use normal variables?
    Concerning the size of the code, it seems that declaring a variable as static is more consuming (for example plus 6 bytes for an object reference).
    So this could mean that declaring variables as static should be avoided, but what about the execution time?
    Some years ago, some javacard gurus were claiming that it's was better to use static variables (less processing required by the JVM to resolve adresses of static variables), but is it still the case?

    Hi Lexdabear,
    Thanks for the answer.
    I did the test (I converted my all code to use static variables and methods as much as possible), and did a bench before and after, on a JCOP31 card.
    The conclusion is that today JVMs and processors are much powerful than 5 years ago, and that the difference is really difficult to measure, which anyway is a good thing for us ;-)

  • I made a pre-booking for ipad2 wifi cellular, i would like to know whether i can upgrade it to IOS6 n IOS7? and i want to know whether can i use 2G network instead of 3G as the 3G network plan is expensive??? and i want to know whether i can access siri ?

    i made a pre-booking for ipad2 wifi cellular, i would like to know whether i can upgrade it to IOS6 n IOS7? and i want to know whether can i use 2G network instead of 3G as the 3G network plan is expensive??? and i want to know whether i can access siri ?

    Siri does Not work on the iPad 2.  iOS 7 is not even out yet, so we have no way of knowing if you'll be able to upgrade to it.

  • Insteade of using mac os on macbook pro, i wanted to install windows 8 pro on mac book pro, will that void my warranty

    insteade of using mac os on macbook pro, i wanted to install windows 8 pro on mac book pro, will that void my warranty

    Installing any OS you want on your machine will not void the warranty.  Only making hardware changes other than those listed as "user servicable" by Apple, or negligence will void your warranty.
    I will warn you that there might be SMC or EFI udates you will want for your Mac hardware that are only available if you are runnign Mac OS.  For this reason, you may want to keep a small partition on your drive which still has Mac OS installed, or at the very least, keep an external HD around to be able to boot Mac OS.  Additionally, if you are having hardware issues, like a failing DVD writer, you may have a harder time getting Apple to repair it under warranty if you can not reproduce the error under Mac OS.  When I had the DVD writer replaced in my first MacBook Pro, I found the problems trying to write discs under Windows 7, but when the tech could reproduce an error under Mac OS, he quickly accepted it was a hardware problem and not software.  Without reproducing it under Mac OS, he admitted that he might not be able to get them to replace the drive.

  • Anyone out there that can maybe help. I was using my 5s to record my meeting minutes for the first time and clicked cancel cos I wanted to continue recording and instead deleted it all! :( anyway to get it back?

    Anyone out there that can maybe help. I was using my 5s to record my meeting minutes for the first time and clicked cancel cos I wanted to continue recording and instead deleted it all! :( anyway to get it back?

    The other Allan is being facetious--you somehow found the forum for pre-2006 eMac desktop computers that gets little traffic.
    Getting you moved to the iPhone forums.

  • HT201302 The laptop I was using to upload photos from my iphone is no longer good and I want to use my desktop instead but it is displaying an error that the iphone has no photos in it. How do I start using my desktop to upload my photos from my iphone5?

    The laptop I was using to upload photos from my iphone is no longer good and I want to use my desktop instead but it is displaying an error that the iphone has no photos in it. How do I start using my desktop to upload my photos from my iphone5, is there any software I need to download?

    Photos on the phone in the DCIM folder are those located in the camera roll. Photos that are synced to the phone from the computer cannot be accessed in this manner. They are synced and the only way to manage them is to connect the phone, go to the photos tab and un-select the folders you want to remove or go into the folder photos are located in and remove the photos you no longer want to sync. Then sync the phone and the photos will be removed.

Maybe you are looking for

  • E-Mail Issues: Retrieved E-Mails deleting off server but only on one of two accounts

    I am the proud owner of a Z10 as of 4 days ago. So far, it's a great device, but I've got one problem. I want the e-mail messages retrieved on my phone to stay on the server, and this is working, but only for one account. I setup my two e-mail accoun

  • I want a GREEN Nokia Lumia 620 - where do I get it...

    Hi,  Why is there a picture of the 620 in green in the store, but It's not possible to buy one? http://www.nokia.com/gb-en/phones/phone/lumia620/offers/?ct=Post&opp=10 It makes me crazy. That's the only colour I want. :/ Otherwise I won't get one. I

  • TDD JUnit

    Hi, I have been trying to use Test driven development and work back from test cases. So far I have these test cases: package poly; import static org.junit.Assert.*; import org.junit.Test; public class ConEqTest {      private int min = Integer.MIN_VA

  • How can I check service user?

    Hi guys, how can I check service user's permission for a certain file. I got the following exception: ResourceExceptioncom.sapportals.wcm.repository.ResourceException: User management exception: Could not get service user "MUTZM" when I used resConte

  • Can't compile class using library

    Hi! I have a simple class which uses library A. This library uses another library B in turn. When I try to complie the classs with javac, I get the message 'cannot access C. file C.class not found' C is the name of the class from library B. I wonder