Multiple values in properties file?

Could someone please tell me the best way to assign and load mulitple values for one property in a properties file?
For example, my properties file might have an entry like this:
columnsToUpdate=FIRST_NAME, LAST_NAME, ADDRESS
So when I call Properties.load(), how can I initialize a String[], instead of a String, on the value(s) of columnsToUpdate? There isn't a method which returns an array that I know of.
Do I have to read it in as a String, then tokenize it manually, and then initialize the String[] on the tokens, or is there a better way?
Thanks,
Erik

Hi,
I'm sorry but appareantly there is an internal problem with the getStringArray method. I didn't realize that, I was only going through the docs.
- You can extend the ResourceBundle class and override the handleGetObject method
- You can use the ListResourceBundle class
- Or you can use a regular Properties object and split the string with the StringTokenizer
I'm sorry for this inconvenience.
Regards,
Kurt.

Similar Messages

  • I am facing problem while reading values from properties file ...i am getting null pointer exception earlier i was using jdeveloper10g now i am using 11g

    i am facing problem while reading values from properties file ...i am getting null pointer exception earlier i was using jdeveloper10g now i am using 11g

    hi TimoHahn,
    i am getting following exception in JDeveloper(11g release 2) Studio Edition Version 11.1.2.4.0 but it works perfectly fine in JDeveloper 10.1.2.1.0
    Root cause of ServletException.
    java.lang.NullPointerException
    at java.util.PropertyResourceBundle.handleGetObject(PropertyResourceBundle.java:136)
    at java.util.ResourceBundle.getObject(ResourceBundle.java:368)
    at java.util.ResourceBundle.getString(ResourceBundle.java:334)
    at org.rbi.cefa.master.actionclass.UserAction.execute(UserAction.java:163)
    at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
    at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
    at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:119)
    at java.security.AccessController.doPrivileged(Native Method)
    at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:315)
    at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:442)
    at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:103)
    at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:171)
    at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:139)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)

  • Multiple replacements in properties file

    I have an entry in a properties file in which I wish to make two replacements, e.g.
    TEST_TEXT=Here is first text {0}. Here is second text {1}
    How can I do the multiple replacements in an ADF outputText? I know the syntax for a single replacement...
    <af:outputText value="#{nls['TEST_TEXT:blah']}" />
    Thanks,
    Gavin

    Hi,
    I'm sorry but appareantly there is an internal problem with the getStringArray method. I didn't realize that, I was only going through the docs.
    - You can extend the ResourceBundle class and override the handleGetObject method
    - You can use the ListResourceBundle class
    - Or you can use a regular Properties object and split the string with the StringTokenizer
    I'm sorry for this inconvenience.
    Regards,
    Kurt.

  • Reading values from properties file

    Hi All,
    I am in need of a help from you all.I have a login.jsp which gets username and password as user input and checks in the servlet that if it was admin and admin it will take to index.jsp and if it was other than admin and other users it should take to index1.jsp.For now i am using an if condition to check the values and to dispatch the request.I need to use a properties file for this and need to check by getting the values from the properties file.And also it should check for each entry in properties file and if it finds any matches it should take to the corresponding page.
    Please help me in achieving this.
    Thanks,
    laxmi

    Hi All,
    I am in need of a help from you all.I have a login.jsp which gets username and password as user input and checks in the servlet that if it was admin and admin it will take to index.jsp and if it was other than admin and other users it should take to index1.jsp.For now i am using an if condition to check the values and to dispatch the request.I need to use a properties file for this and need to check by getting the values from the properties file.And also it should check for each entry in properties file and if it finds any matches it should take to the corresponding page.
    Please help me in achieving this.
    Thanks,
    laxmi

  • Multiple use of properties file

    Is there a way to use a properties file for multiple languages?
    ie.
    en_EN points to the en_EN properties file
    I want en_US to also point to that, is this possible? (it now points to default language if not present)
    And anyone got a good tutorial / overview of the possibilities of properties file? have not been able to find a good example that shows all possibilities
    Thanks

    Provide an en version which contains all the English stuff, then put all the en_US and en_EN variants into those files respectively.

  • How to read multiple files at multiple locations using properties file

    hi all ,
    in my code i take configuration input from a properties file ,it was really easy but what if there are multiple files ? how can i take configuration input (file path etc) from properties file in that case ? any suggestion ?

    thanks :) ..i am doing like this :
    String fName[]=new String[10];
              String choice[]=new String[10];
              String Delim[]=new String[10];
              ResourceBundle a = ResourceBundle.getBundle("input");
              String n=a.getString("NOF");
              try
                   for(int i=0;i<Integer.parseInt(n);i++)
                        fName=a.getString("PATH"+(i+1));
                        choice[i]=a.getString("HEADER"+(i+1));
                        Delim[i]=a.getString("DELIMITER"+(i+1));
                        putData(fName[i],choice[i],Delim[i]);//to put data in database
              catch (NumberFormatException e)
                   System.out.println("Number of files are invalid");
    hope this method would be fine ....again thanks for the advice :) :)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How can i remove a key and its value from properties file

    hi all,
    i want remove a particular key and associated value from the
    properties file. is their any standard way of doing?
    thanks inadvance
    daya

    hi,
    thanks
    i am able to remove the key,
    one more question how can avoid storing date and time
    in properties file.
    thanks
    daya

  • Best approach to change values in .properties file dynamically

    Hi ,
    I am using Jdev 11.1.1.5 . I wanted to change the values used in .properties file (like say a fe email addresses which happen to be different for Test/Prod/Dev instances) dynamically using something like a deployment plan.
    One way to do the same is to include it in a shared libary and do a one -time deployment to the server.
    Are there any better ways like a deployment plan , which unfortunately I think can change values dynamically on for web.xml , weblogic.xml type of files.

    I am using a shared library which takes care of the cases mentioned above.

  • ServletContext Vs Properties file

    Dear Friends,
    My question is related to optimization.
    In our Servlet application, We have to read some values
    from properties files. In this which one is better from the following
    or is there any better way of doing?
    1. Reading from the Properties file everytime required. (So for each user the Properties file have to be accessed)
    or
    2. Reading from the Properties file once in the init method of the servlet and store those in the Servlet Context variables and use it whenever required.
    Please suggest me the best way.
    Thanks in advance.
    Regards,
    Goudham

    I think the best way would be to read the property
    file one time and store it as a hashtable and the last
    modified date, stored as a Long, should be stored up
    in a Hashtable, keyed on the filename. The Properties
    should be loaded from the file only if the last
    modified time in the Hashtable is less than the last
    modified time of the file, or if the filename isn't
    found. This insures that a modification check is done
    for each Properties file individually, and that they
    are all continually up to date. Also on server
    restart, all files are reloaded since they aren't
    initially listed in the Hashtable.
    Just a opinion
    -AsheeshThanks!
    If I understand correctly, Read the Properties file once and store the Key Value pairs in a Hashtable then maintain this Hashtable in ServletContext? Is this correct?
    - Goudham

  • How we write into properties file using get class method

    Hi
    I want to set some value into properties file using given code
    can any one please tell me how i can do this.
    property file
    setting.properties
    Name     =     abc
    and code I use is
    java.io.InputStream oInputStream = this.getClass().getResourceAsStream("Setting.properties");
                   Properties obj = new Properties();
                   obj.load(oInputStream);
                   String myName = obj.getProperty("Name");
                   System.out.println("myName :"+myName);
                   obj.setProperty("Name","def");
                   FileOutputStream oOutput= new FileOutputStream("Setting.properties");
                   obj.store(oOutput, "");
    thanks.

    You can't.
    If you have properties that change dynamically, you should not be using a properties file that sits in the classpath, you should be using Preferences, or a properties file that sits in some application or possibly even user directory, but not one in the classpath. The proper way to do this, would be to have a properties file in your jar (or otherwise in your classpath) that contains the defaults, and another one outside of the classpath in one of the twwo above mentioned areas, then, you read the default one only if the other doesn't exist, or you read the default one first, then read the other overwriting the values from the defaults.
    Don't forget to save the properties again (right after loading if you loaded, or always load, the defaults) after every change.

  • XML parser for fatching multiple values from XML

    Hi,
    In my scenirio i have to facth multiple values from XML file and then set in to Table in webdynpro...
    Fo example my xml has values like...
    <xml>
         <item>
              <item1>
                   <quantity>
                        100
                   </quantity>
                   <price>
                        50
                   </price>
              </item1>
              <item2>
                   <quantity>
                        200
                   </quantity>
                   <price>
                        20
                   </price>
              </item2>
              <item3>
                   <quantity>
                        300
                   </quantity>
                   <price>
                        10
                   </price>
              </item3>
         </item>
    </xml>
    then i have to fcath those quantity and price and set in to table...
    How to do taht in webdynpro and does any one have parser code for retriving multiple values...

    Hi,
    1) You need to use JDOM parser.
    2) The code for parsing XML using JDOM parser is readily available if you search on google.
    3) You will have to check the attribute during every parsing and then if attribute is quantity you can fetch the corresponding tags.
    4) Something similar to this:
    org.jdom.Document document = parser.build(file);
                    org.jdom.Element rootElement = document.getRootElement();
                    org.jdom.Element childElement = rootElement.getChild("file");
                    Element xmlElement = childElement.getChild("item");
                    if (xmlElement != null) {
                        List itemElementsList = xmlElement.getChildren("item1");
                        if (itemElementsList != null) {
                            Iterator iterator3 = itemElementsList.iterator();
                            while (iterator3.hasNext()) {
                                //For each group get quantity
                                Element itemElement = (Element) iterator3.next();
                                List quantityElementsList =
                                        itemElement.getChildren("quantity");
                                if (quantityElementsList != null) {
                                    Iterator iterator2 =
                                            quantityElementsList.iterator();
                                    while (iterator2.hasNext()) {
    // Your code                                                                               
    You might need to make some changes as per your rquirement. Just use this sample to understand how you need to parse the xml
    Hope it helps.
    Regards.
    Rajat
    Edited by: Rajat Jain on Jan 22, 2009 9:51 AM

  • How Can i specify multiple server names in rwservlet.properties  file?

    How Can i specify multiple server names in rwservlet.properties file without clustering?
    I am using oracle 10g Application server. we have 3 servers Repsvr1, RepSvr2 and RepSvr3. Now i need to configure rwservlet.properties file to point to these servers based on any running report. i got 3 keymap files with reports info.
    Sample entry in the key map file is:
    key1: server=Repsvr1 userid=xxx/yyy@dbname report=D:\Web\path1\path2\reports\Report1.rdf destype=cache desformat=PDF %*
    key2: server=Repsvr2 userid=xxx/yyy@dbname report=D:\Web\path1\path3\reports\Report2.rdf destype=cache desformat=PDF %*
    rwservlet.properties file letting me to enter only one servername. Even though i merged all 3 keymap files into 1, still i have the server name issue. If i leave the server to the default name still i am getting the below error.
    REP-51002: Bind to Reports Server Repsvr1 failed. However, i know the default rep_<servername> would be used incase we dont have SERVER=<value> parameter in the rwservlet.properties file.
    If i specify the servername in the rwservlet.properties file then only Repsvr1 reports are working fine and other 2 server reports are giving the same error like
    REP-51002: Bind to Reports Server <<Server Name>> failed.
    how can i configure the info which will work all 3 reports. 2 Port servers are invoking using oracle forms and report server is invoking using ASP pages.
    If i specify Server name & Key map file in rwservlet.properties one at a time, all the reports are working without any error, whenever i am trying to integrate all 3 to workable i am getting binding error. if i exclude the server from rwservlet.properties still i am getting the same error.

    My RELOAD_KEYMAP setting is YES only.As i said If i specify Server name & Key map file in rwservlet.properties one at a time, all the reports are working without any error.
    keymap file entries
    key1: server=Repsvr1 userid=xxx/yyy@dbname report=D:\Web\path1\path2\reports\Report1.rdf destype=cache desformat=PDF %*
    key2: server=Repsvr2 userid=xxx/yyy@dbname report=D:\Web\path1\path3\reports\Report2.rdf destype=cache desformat=PDF %*
    If i use http://server.domain:port/reports/rwservlet? cmdkey = key1 should bring the report from Repsvr1 and http://server.domain:port/reports/rwservlet? cmdkey = key2 should bring the report from Repsvr2, but i am getting an error from Repsvr2 saying that REP-51002: Bind to Reports Server repsvr2 failed.
    Only Servername Repsvr1 is in rwservlet.properties file. Now what is the best option to by pass the server from rwservlet.properties file and should be from keymap file. if i comment server name in rwservlet.properties file still i am getting REP-51002: Bind to Reports Server <<Server Name>> failed error for both keys.

  • Using Multiple Properties Files in Struts Framework

    Hi Everybody!
    I just to know how to use a multiple message-resources files in a Struts Framework.
    I've 2 properties file :
    1. ApplicationResources_A.properties
    2. ApplicationResources_B.propertiesI put the files under WEB-INF/classes dir.
    My configuration in struts-config file something like below:
    <!--  Begin Testing -->
         <message-resources key="A" parameter="ApplicationResources_A" />
         <message-resources key="B" parameter="ApplicationResources_B" />
    <!--  End Testing -->
    </struts-config>
    if my JSP code is like below , this error is thrown:
    org.apache.jasper.JasperException: Cannot find message resources under key A
      <tr>
        <td width="17%">Language A</td>
        <td width="83%"><bean:message bundle="A" key="user.lang.desc"/></td>
      </tr>
      <tr>
        <td width="17%">Language B</td>
        <td width="83%"><bean:message bundle="B"  key="user.lang.desc"/></td>
      </tr>
    but  if I change the  JSP code like below it  work fine:
      <tr>
        <td width="17%">Language A</td>
        <td width="83%"><bean:message key="user.lang.desc"/></td>
      </tr>
      <tr>
        <td width="17%">Language B</td>
        <td width="83%"><bean:message  key="user.lang.desc"/></td>
      </tr>
    In this code , I dont know  which resources file is used.
    So how do I solve this problem. Thanks you.

    I have defined the following:
    struts-config.xml
    <message-resources key="ldap" parameter="com/project/struts/ldap"/>
    Action.java
    In execute method:
    MessageResources messageResources= MessageResources.getMessageResources("com/project/struts/ldap");
    System.out.println("INITIAL_CONTEXT_FACTORY"+messageResources.getMessage("INITIAL_CONTEXT_FACTORY"));
    and it is working, however I have to change "com/project/struts/ldap" value in Action.java file whenever there is any change in name or location of ldap.properties.
    Can I access this properties in such way that I don't have to change parameter path manually in Action.java (modifying in struts-config.xml is okay)? like access through key="ldap" or something.
    Thanks and regards,

  • Issue in reading multiple time properties file

    Use Case:
    I have a page in which i have to show some Outage Messages on page. So I have configured outage message in properties files. This message should me rendered each time when it finds that properties file in class path or it finds the values w.r.t their keys.
    So what I decide that I shall write java method and call this method on Loading the page but here what happen is that whenever that page is load each time that reader file will call , that will create memory leak .
    So, anyone help me on this. What will be the best approach for that reading multiple times properties file?
    I will be grateful for any help you can provide
    Thanks

    Hi,
    have a bean at applicationScope, somewhat like this
    import java.util.HashMap;
    public class ApplnProperties {
        private HashMap _propMap;
        public HashMap getPropMap() {
            if(_propMap == null){
                //read the properties file and populate _propMap
            return _propMap;
    }here we put condition _propMap == null so it would be called only once during application lifecycle.
    and on page you can refer the prop map like following
    #{beanName.propMap['KEY1']}Regards,

  • Creating multiple profiles, using unified profile types, to store multiple values for same properties

    Hi All:
    I am trying to create multiple profiles, using unified profile types, to
    store multiple values for same properties. Here my intention of using
    'unified profile types' is to create multiple profiles (to store multiple
    values for a property). All the properties are stored in the same database
    maintained by Personalization server. Also, I am trying to use the same
    'USER' ejb as profile class/home/pk/jndi.
    The scenerio is,
    define unified profile types (Business, Vacation) using Personalization
    admin tools, using com.beasys.commerce.axiom.contact.User,
    com.beasys.commerce.axiom.contact.UserHome,
    com.beasys.commerce.axiom.contact.UserPk,
    com.beasys.commerce.axiom.contact.User for Profile Class, Home, Pk class,
    JNDI name respectively.
    Define Property set 'HotelCommerce' with property
    HotelProp as single, restricted, text (valid values Single, Double)
    Now you can use the attached jsp files to login as a user and try to set the
    property value for HotelProp for each profile. As per my understanding, I
    was expecting that I can set different values for the property 'HotelProp'
    for each profiles. But unexpectedly, all the profiles get the same value.
    Question. is it the correct behavior? if yes, how can I achieve this
    functionality?
    if not, do you see any problem in my scripts?
    your answer asap is appreciated. we need to make decision on using
    Personalization server v/s developing our own Personalization server!!!:)
    thanks,
    -rajesh
    PS: I have tried 'Unified Profile Example' type too, but that did not work.
    [propsettest.jsp]
    [home.jsp]

    I am trying to create multiple profiles, using unified profile types, to
    store multiple values for same properties. Here my intention of using
    'unified profile types' is to create multiple profiles (to store multiple
    values for a property). All the properties are stored in the same database
    maintained by Personalization server. Also, I am trying to use the same
    'USER' ejb as profile class/home/pk/jndi.Hello Rajesh,
    This is not the purpose of the UUP. The UUP is used to allow existing
    database schemas to be aggregated with the existing Weblogic Personalization
    Server database schema to provide a single, customized user profile with which
    to maintain the user properties (
    http://e-docs.bea.com/wlcs/p13n/users.htm#1068901 )
    If you want to have properties that change value based on some "profile" or
    classification of a user, then you should use classifier rules to change the
    user from "OnVacation" to "AtWork" or "AtHome". You can use these classifier
    rules to select content for the user or conditionally execute logic (
    http://e-docs.bea.com/wlcs/p13n/rules.htm )
    Ture Hoefner
    BEA Systems, Inc.
    1655 Walnut Street; suite 200
    Boulder, CO 80302
    www.beasys.com

Maybe you are looking for

  • Wake from sleep when docked to Mini Dock using USB mouse or keyboard attached to dock

    I'd like to know how to wake a T520 connected to Mini Dock (type 4338). I have a basic USB mouse (wired) connected directly to the dock.  I've verified all of the items in Device Manager (mice and USB ports) are enabled for "waking the computer". In

  • Mb5B or ZMB6B report

    Hi All my MM staff would like to see more columns such as Account Assignment (G/L account & cost center) after double click the  material no in above report. She wanted to know daily GI documents entered to the system to review the G/L account and co

  • Multiple i pod question

    my brother had an i pod first then i bought an i pod touch and it worked great then he bought an i pod touch and now the apps go to his i tunes account not mine ....any way to switch this....its really annoying... we share a computer and ive tried lo

  • Error message says itunes is open when its not, when trying to DL lateset Version

    Im trying to DL newest version of iTunes, box pops up that i must close itunes to finish installation, yet iTunes isnt open!??! I have restarted and still gotten same message. thanks!!

  • 'BAPI_DOCUMENT_CREATE2': file attachment

    Hi experts !! I have a problem with this Bapi "BAPI_DOCUMENT_CREATE2". I can attach a file manually in CV01N.But when i try to attach a file using this BAPI - file not getting store.Following is my code, ls_doc-documenttype    = 'DRW'. ls_doc-documen