Initializing Application Params (web.xml vs. Properties file)?

Hi Friends,
Basically a question where I do not have much experience...
I think that I have the choice of initializing web application wide parameters either with:
a) Properties file (text file as managed by the Properties framework) or,
+ Here it is easy to read, modify parameters, ...
- I dislike the deployment (manual procedure of storing the file in a particular directory...)
b) web.xml (deployment descriptor) and "context-param".
- The problem here is that it does not seems "easy" to change the deployed values in a web.xml from a java program.
+ Very easy to deploy (war, ear files)
I would like to implement a solution that is:
* Easy for the end-user to change its values
* Easy to deploy and configure
From some testing, I think that the properties file (and framework) is a better solution, but not sure...Any more expert advice?
Thanks in advance!

A properties file is often used with parameters that vary depending on a particular Locale. Under these circumstances, I find it impractical to store the file in an archive because the user in a given Locale may want to use the original file as a template to create a new Locale-specific version.
Whenever I need to initialize my application with parameters that are totally under my control (e.g., when the parameters do not vary by Locale but new ones may be added or old ones removed), I often use just a plain .txt file kept inside of an archive file like a jar and access it file with something like this:
URL url=myDialog.class.getResource("Params/myParams.txt");
That's just my 2-cents.
V.V.

Similar Messages

  • Error in parsing taglib 'customtag' tag in web.xml or .tld file of the tagl

    Hi
    While execution Portal application, I am getting error," Error in parsing taglib 'customtag' tag in web.xml or .tld file of the taglib library."
    Complete stack is
    >>#1.5 #005056AE006400690000002000000A440004BA8F3ECB004A#1331024303056#com.sap.portal.prt.runtime#sap.com/irj#com.sap.portal.prt.runtime#M1005000#6994##99593FD6676911E1807500000041A352#99593fd6676911e1807500000041a352-0#99593fd6676911e1807500000041a352#SAPEngine_Application_Thread[impl:3]_31##0#0#Error##Java###02:28_06/03/12_0020_4301650
    [EXCEPTION]
    #1#com.sapportals.portal.prt.servlets_jsp.server.jsp.ParseException: Error in parsing taglib 'customtag' tag in web.xml or .tld file of the taglib library.
    at com.sapportals.portal.prt.servlets_jsp.server.jsp.syntax.JspTaglibDirective.verifyAttributes(JspTaglibDirective.java:189)
    at com.sapportals.portal.prt.servlets_jsp.server.jsp.syntax.JspDirective.parse0(JspDirective.java:162)
    at com.sapportals.portal.prt.servlets_jsp.server.jsp.syntax.JspDirective.parse(JspDirective.java:117)
    at com.sapportals.portal.prt.servlets_jsp.server.jsp.syntax.ElementCollection.parse(ElementCollection.java:86)
    at com.sapportals.portal.prt.servlets_jsp.server.jsp.syntax.ParserImpl.parse(ParserImpl.java:595)
    at com.sapportals.portal.prt.servlets_jsp.server.jsp.JSPParser.parse(JSPParser.java:2170)
    at com.sapportals.portal.prt.servlets_jsp.server.jsp.JSPCompiler.compile(JSPCompiler.java:81)
    at com.sapportals.portal.prt.servlets_jsp.server.jsp.JSPCompiler.run(JSPCompiler.java:140)
    at com.sapportals.portal.prt.core.broker.JSPComponentItem.compileJSP(JSPComponentItem.java:291)
    at com.sapportals.portal.prt.core.broker.JSPComponentItem.getComponentInstance(JSPComponentItem.java:141)
    at com.sapportals.portal.prt.core.broker.PortalComponentItemFacade.service(PortalComponentItemFacade.java:355)
    at com.sapportals.portal.prt.core.broker.PortalComponentItem.service(PortalComponentItem.java:934)
    at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:435)
    at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:527)
    at com.sapportals.portal.prt.component.AbstractComponentResponse.include(AbstractComponentResponse.java:89)
    at com.sapportals.portal.prt.component.PortalComponentResponse.include(PortalComponentResponse.java:232)
    at com.sapportals.portal.htmlb.page.JSPDynPage.doOutput(JSPDynPage.java:76)
    at com.sapportals.htmlb.page.PageProcessor.handleRequest(PageProcessor.java:133)
    at com.sapportals.portal.htmlb.page.PageProcessorComponent.doContent(PageProcessorComponent.java:134)
    at com.sapportals.portal.prt.component.AbstractPortalComponent.doPreview(AbstractPortalComponent.java:240)
    at com.sapportals.portal.prt.component.AbstractPortalComponent.serviceDeprecated(AbstractPortalComponent.java:168)
    at com.sapportals.portal.prt.component.AbstractPortalComponent.service(AbstractPortalComponent.java:114)
    at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:328)
    at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:136)
    at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:189)
    at com.sapportals.portal.prt.component.PortalComponentResponse.include(PortalComponentResponse.java:215)
    at com.sapportals.portal.prt.pom.PortalNode.service(PortalNode.java:645)
    at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:328)
    at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:136)
    at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:189)
    at com.sapportals.portal.prt.core.PortalRequestManager.runRequestCycle(PortalRequestManager.java:753)
    at com.sapportals.portal.prt.connection.ServletConnection.handleRequest(ServletConnection.java:240)
    at com.sapportals.portal.prt.dispatcher.Dispatcher$doService.run(Dispatcher.java:545)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sapportals.portal.prt.dispatcher.Dispatcher.service(Dispatcher.java:434)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:401)
    at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:266)
    at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:386)
    at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:364)
    at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:1060)
    at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:265)
    at com.sap.engine.services.httpserver.server.Client.handle(Client.java:95)
    at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:175)
    at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
    at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
    at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:104)
    at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:176)
    Regards
    Pratyush

    Hi,
    See the following guide and make sure to carefully follow all instructions.
    [http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/40599e45-8cf9-2910-cbaa-d4cd8e15ff34?QuickLink=index&overridelayout=true&14770392545262]
    Regards,
    Alex

  • Error in parsing taglib taglib tag in web.xml or .tld file of the taglib

    Hi All,
    I have added ResourceBundle.tld file in following path : /PORTAL-INF/taglib/tld/
    I have added portalapp.xml file following entry  :
    <property name="/PORTAL-INF/taglib/tld/ResourceBundle.tld" value="/PORTAL-INF/taglib/tld/ResourceBundle.tld"/>
    I have added jsp file following entry :
    <%@ taglib uri="/PORTAL-INF/taglib/tld/ResourceBundle.tld" prefix="bundle" %>
    I am getting the following the error: Error in parsing taglib taglib tag in web.xml or .tld file of the taglib library
    can you tell me where i am giving the wrong.
    Regards
    Siva

    hi rabih,
    in jsp..
    <%@ taglib uri="tagLib" prefix="bundle" %>
    in portalapp.xml
    <component-profile>
      <property name="tagLib" value="/PORTAL-INF/taglib/tld/ResourceBundle.tld"/>
    </component-profile>
    it may help u..
    regards,
    Chinnadurai.R

  • Web application and web.xml

    i have a web application consisting of 1 servlet and 5 jsps.
    the start point would be index.jsp
    i use firmwide login page. after login, i want the browser to display index.jsp page.
    In web.xml, i have defined -
    <welcome-file-list>          <welcome-file>/jsp/index.jsp</welcome-file>     </welcome-file-list>       <servlet>        <servlet-name>UtilitiesServlet</servlet-name>        <servlet-class>com.gs.fw.sox404.utilities.UtilitiesServlet</servlet-class>             <init-param>             <param-name>util-log4j-init-file</param-name>             <param-value>/WEB-INF/classes/util_log4j.properties</param-value>          </init-param>        <load-on-startup>1</load-on-startup>    </servlet>     <servlet-mapping>        <servlet-name>UtilitiesServlet</servlet-name>        <url-pattern>/UtilitiesServlet</url-pattern>    </servlet-mapping>if i define it as just index.jsp in the welcome file list, after successful login, it displays the dir structure of the web app.
    if i define it as jsp/index.jsp, then in some of the pages, it tries to find the servlet inside jsp folder.
    What would be the best way to get around this?

    Well, yes, it's not able to find it because you've not understood the mechanism of how it works clearly. You have to put your welcome file under every directory you want it to be used from. Like I said, it's not a path, it's a filename. So if the container sees that your request URL is for a directory, it'll look for the welcome files from the welcome file list, one by one, in the order of declaration. Whichever one it finds first, it'll serve that. If it doesn't find any, then it'll either give a 404 or a directory listing depending on the server and it's settings.
    So your problem is that you've put your index.jsp in your JSP folder but expect it to be served for all URLs. That won't happen, you'll have to put one file named index.jsp into every directory. The reasoning is pretty simple, what if you want different behaviour for each folder?
    This should fix your problem :)
    People on the forum help others voluntarily, it's not their job.
    Help them help you.
    Learn how to ask questions first: http://faq.javaranch.com/java/HowToAskQuestionsOnJavaRanch
    ----------------------------------------------------------------

  • How can I change application's web.xml in NetWeaver CE 7.1?

    Hello Experts,
    Please help me. I need to configure a J2EE application on NetWeaver 7.1, but I don't know how I can change the web.xml of the application.
    The web.xml of the app needs to be modified during the configuration. This can be achieved via single-file-update in VA in Netweaver 6.4 or 7.0. But I cannot figure out how to do that in NW 7.1.
    Please show me how to do that or at least give me some hints.
    Thank you!
    Jack

    Hi Jack,
    In SAP NetWeaver 7.1 and later, you use the SAP NetWeaver Administrator instead of Visual Administrator.
    To get some information on how to configure web applications, try [THIS|http://help.sap.com/saphelp_nwce10/helpdata/en/45/48a60a528608d1e10000000a11466f/frameset.htm] piece of documentation.
    I hope it helps.
    Best,
    Yordan

  • WEB-INF and properties files

    okay, this may be really naive and maybe i'm missing some key piece of
    documentation, but i'm missing something regarding the file structure with
    iplanet enterprise 4.1 on solaris.
    in my /usr/local/netscape/suitespot there's a docs directory that is the
    default docs directory.
    I've created a /WEB-INF directory under docs and a /classes directory under
    that. I've placed a jay.properties file in the /WEB-INF/classes directory,
    but when I try to access that through a servlet instantiated bean, I get an
    error from the ResourceBundle call, telling me that it can't load that
    properties file.
    I have two questions:
    1. did i build the WEB-INF directory in the correct place (ie - is this the
    standard way of working under the iplanet server) - this doesn't seem to be
    supported by the admin server in the sense that i can browse this directory,
    when i'd expect that iplanet would build in some basic security around the
    WEB-INF directory
    2. what do i name and where do i put the properties file? should it be
    jay_en.properties? i've tried a number of different scenarios with no luck.
    thanks...
    jay

    Why would you create a WEB-INF directory on the web tier?
    WEB-INF is a directory with a special meaning to the web container. All
    of your properties files and such will need to be placed on the
    application server tier, in the WEB-INF directory that was automatically
    created there. And you can do that just be properly placing them in the
    WAR file.
    David
    Jay Wright wrote:
    > okay, this may be really naive and maybe i'm missing some key piece
    > of documentation, but i'm missing something regarding the file
    > structure with iplanet enterprise 4.1 on solaris.
    >
    > in my /usr/local/netscape/suitespot there's a docs directory that is
    > the default docs directory.
    >
    > I've created a /WEB-INF directory under docs and a /classes
    > directory under that. I've placed a jay.properties file in the
    > /WEB-INF/classes directory, but when I try to access that through a
    > servlet instantiated bean, I get an error from the ResourceBundle
    > call, telling me that it can't load that properties file.
    >
    > I have two questions: 1. did i build the WEB-INF directory in the
    > correct place (ie - is this the standard way of working under the
    > iplanet server) - this doesn't seem to be supported by the admin
    > server in the sense that i can browse this directory, when i'd
    > expect that iplanet would build in some basic security around the WEB-INF
    > directory
    >
    > 2. what do i name and where do i put the properties file? should it
    > be jay_en.properties? i've tried a number of different scenarios
    > with no luck.
    >
    > thanks... jay
    >
    >
    >

  • Automatic update of web.xml when running UIX application

    I moved my UIX project from 9.02 to 9.03. The UIX resource files have changed between the versions so I deleted the old cabo folder so that when I ran my applicaton for the first time it would rebuild it. When I ran my application my web.xml file was automatically updated with the following servlet initialisation parameters:
    <init-param>
    <param-name>oracle.cabo.servlet.pageBroker</param-name>
    <param-value>oracle.cabo.servlet.xml.UIXPageBroker</param-value>
    </init-param>
    <init-param>
    <param-name>oracle.cabo.ui.UIExtensions</param-name>
    <param-value>oracle.cabo.data.jbo.ui.JboUIExtension</param-value>
    </init-param>
    The problem is that I've got my own pageBroker already defined in web.xml so when I run my application it used UIXPageBroker instead. This took me a while to find - my app just suddenly stopped working. I don't know what actually updated web.xml but I think it needs to check for the presence of these parameters before inserting them.
    Cheers
    Ian

    Sorry about that Ian, I agree that the code should
    check for the presence of another PageBroker. I'll
    log a bug and bring this up with the development
    team.
    - Jeff

  • PLEASE HELP. How do you access properties files in WEB-INF  and classes directory

    We have a war file that needs to access properties files that are in the WEB-INF directory
    of the war file. We also need to load one of the properties files from the classpath.
    However, when we deploy the application ( an ear which inlcludes an ejbjar and a
    war and the libraries both the ejbjar (with a manifest setting the classpath ) and
    war need ) the properties don't get extracted.
    In some of our servlets we are trying to access those files with the path "WEB-INF/foo.properties"
    and we get a FileNotFoundException. Then we check and see that NO properties files
    have been extracted into their appropriate places ( not even those we throw into
    the WEB-INF/classes directory ).
    PLEASE HELP,
    Christian Hargraves

    The file doesn't have to be extracted from the war. For example, you can place
    test.properties into your app WEB-INF and write a simple JSP to see how it
    works:
    <%
    InputStream in = application.getResourceAsStream("/WEB-INF/test.properties");
    %>
    It will return you a zip inputstream if you deployed your application as a .war.
    Christian Hargraves <[email protected]> wrote:
    I try this, but I get a NullPointerException. The file never actually gets extracted
    from the war. Under tomcat and resin this works great ( that's why I am having all
    of the trouble i am having ), but there are absolutely no properties files in the
    extracted directories for WebLogic deploys. only:
    WEB-INF/some_tmp_dir/WEB-INF/lib
    and then some dynamically generated jor file with all of the classes that would normally
    go in WEB-INF/classes ( all except the properties, of course, which are no where
    to be found. ).
    There has to be some kind of setting I am missing. Please don't make me seperate
    these properties files from the war/ear and then put the path to these properties
    files in the CLASSPATH, changing one step to three steps to deploy!!
    I have found a documented bug where you can't even put the properties files in a
    jar file and that bug will never be fixed for WebLogic 6.1.
    "Dimitri I. Rakitine" <[email protected]> wrote:
    To access files in WEB-INF you can use ServletContext.getResourceXXX("/WEB-INF/filename")
    Christian Hargraves <[email protected]> wrote:
    We have a war file that needs to access properties files that are in theWEB-INF directory
    of the war file. We also need to load one of the properties files fromthe classpath.
    However, when we deploy the application ( an ear which inlcludes an ejbjarand a
    war and the libraries both the ejbjar (with a manifest setting the classpath) and
    war need ) the properties don't get extracted.
    In some of our servlets we are trying to access those files with the path"WEB-INF/foo.properties"
    and we get a FileNotFoundException. Then we check and see that NO propertiesfiles
    have been extracted into their appropriate places ( not even those wethrow into
    the WEB-INF/classes directory ).
    PLEASE HELP,
    Christian Hargraves--
    Dimitri
    Dimitri

  • (newbie) Question about replacing .class files and web.xml file

    I'm new to servlets and I have two quick questions...
    Do I absolutely need a web.xml file to define all my servlets, or can I simply place .class files into the WEB-INF directory and expect them to run?
    If my application server (for example Tomcat) is running and I replace a servlet .class file, do I need to restart the server for the new .class file to take effect?
    ...or are both of these questions specific to the application server I'm using?

    Hi,
    From an article I read:
    With Tomcat 3.x, by default servlet container was set up to allow invoking a servet through a common mapping under the /servlet/ directory.
    A servlet could be accessed by simply using an url like this one:
    http://[domain]:[port]/[context]/servlet/[servlet full qualified name].
    The mapping was set inside the web application descriptor (web.xml), located under $TOMCAT_HOME/conf.
    With Tomcat 4.x the Jakarta developers have decided to stop allowing this by default. The <servlet-mapping> tag that sets this mapping up, has been commented inside the default web application descriptor (web.xml), located under $CATALINA_HOME/conf:
    <!-- The mapping for the invoker servlet -->
    <!--
    <servlet-mapping>
    <servlet-name>invoker</servlet-name>
    <url-pattern>/servlet/*</url-pattern>
    </servlet-mapping>
    -->
    A developer can simply map all the servlet inside the web application descriptor of its own web application (that is highly suggested), or simply uncomment that mapping (that is highly discouraged).
    It is important to notice that the /servlet/ isn't part of Servlet 2.3 specifications so there are no guarantee that the container will support that. So, if the developer decides to uncomment that mapping, the application will loose portabiliy.
    And declangallagher, I will use caution in future :-)

  • My application gives "Error in parsing taglib 'tagLib' tag in web.xml "

    Hi ,
    My Portal application developed completely on JSP Dynpages and JSPs gives <b>at times</b> the following error
    "Error in parsing taglib 'tagLib' tag in web.xml or .tld file of the taglib library.."
    I know that this error comes when the taglib declared in the jsp and portalapp.xml doesn't match. But I have made sure that they are the same.
    Can anyone give me an opinion as to why this problem is occuring inspite of making sure that the taglib declaration are same in jsp and portalapp.xml.
    Is the problem on the server side??
    Valuable suggestions would be rewarded!!
    -Thanks
    Padmarajan.

    Hi Anagha,
    No the application is accessed using an http link.
    I am unable to make out why this error comes up only once in a while and when you refresh the screen it starts working fine.
    This is my big issue because when
    -Thanks
    Padmarajan.

  • How to handle multiply properties.files in combined applications

    I have some applications bundled into one jar for each application. The applications make all use of a properties.file in it's own /resources/ folder within the jarfile.
    To avoid running each application on the desktop with it's own JVM and as seperate programs, I wrote a menuprogram which can start the applications within a splitted pane. Left pand is a JTree menu, right side is the applicationspace. This way i have only one JVM active and all app's can be accessed from within a single window. This menu applications also has it's own properties.file.
    I noticed that the applications now all use the same properties.file which is actually not correct. The file used is the one which belongs to the menu application.
    So i have : menu.jar, app1.jar, app2.jar, appn.jar
    The menu.jar is started and from within this application i run the other applications (jInternalFrames). All apps seems to see only the properties.file within the menu.jar IMHO because i create the objects from app1, app2 and appn from within the menu.
    QUESTION:
    How can i change the code to force each app.object to use the propsfile delivered in his own jar-file?
    Here's a code snippet used in each application.
    setPropertiesFileName("/resources/application.properties");
    try {
    is_ = getClass().getResourceAsStream(propertiesFileName);
    props.load(is_);
    catch(Exception e){
    // Debug Props
    setDEBUG_LEVEL(props.getProperty("DEBUG_LEVEL"));
    setTRACE_ENABLED(props.getProperty("TRACE_ENABLED"));
    ...

    You can do this, but is it generally a bad idea which can turn into a nightmare to manage.
    Instead each application should use a different properties file. Is there a good reason every application proeprties must have the same name and path?

  • Application specific properties file

    Hello
              Can any body help me how to build application specific properties file
              so that we can have independent application specific server with its own
              java class path environment.I read the procedure in beasys manuals but i
              could'nt understand clearly.
              Setting application-specific properties
              The weblogic.properties file is only accessible by WebLogic; that is,
              you can't add application-specific properties to the weblogic.properties
              file and expect that they will be read at startup time. However, you can
              set properties for your own application by creating a separate
              properties file. This file can be created and used in two ways:
              Put your application-specific properties file in the same directory as
              your weblogic.properties file. You can then use the following code to
              access the properties:
              Properties props = new Properties();
              String propertiesName = "myapp.properties";
              T3ServicesDef services =
              T3Services.getT3Services();
              String location =
              services.config().getProperty("weblogic.system.home") +
              java.io.File.separator + propertiesName;
              props =
              props.load(new DataInputStream(new FileInputStream(location)));
              Thanks in advance
              Ravi
              

    Hi, Ravi.
              I think I am "WeiG".
              Basically, you can not put your own properties on weblogic.properties. Every
              property in weblogic.properties managed by WLAS is pre-registered in WLAS
              internally. WLAS will print "Fund undefined property ...." messages for the
              un-registered property in weblogic.properties files.
              To use your application-specific properties, the paragraph you read suggests
              you create your own file, put it in $WL_HOME, and use the example code to
              read your own file.
              Hope it helps.
              Cheers - Wei
              Ravi <[email protected]> wrote in message
              news:[email protected]...
              > Hi Purdy
              >
              > Who is WeiG,can you tell me please
              >
              > Thanks
              > Ravi
              >
              > Cameron Purdy wrote:
              >
              > > I know that WeiG has answered this before ... try to ask Wei directly.
              > >
              > > --
              > >
              > > Cameron Purdy
              > > http://www.tangosol.com
              > >
              > > "Ravi" <[email protected]> wrote in message
              > > news:[email protected]...
              > > > Hello
              > > >
              > > > Can any body help me how to build application specific properties file
              > > > so that we can have independent application specific server with its
              own
              > > > java class path environment.I read the procedure in beasys manuals but
              i
              > > > could'nt understand clearly.
              > > >
              > > > ************************
              > > > Setting application-specific properties
              > > > The weblogic.properties file is only accessible by WebLogic; that is,
              > > > you can't add application-specific properties to the
              weblogic.properties
              > > > file and expect that they will be read at startup time. However, you
              can
              > > > set properties for your own application by creating a separate
              > > > properties file. This file can be created and used in two ways:
              > > >
              > > > Put your application-specific properties file in the same directory as
              > > > your weblogic.properties file. You can then use the following code to
              > > > access the properties:
              > > >
              > > > Properties props = new Properties();
              > > > String propertiesName = "myapp.properties";
              > > >
              > > > T3ServicesDef services =
              > > > T3Services.getT3Services();
              > > > String location =
              > > > services.config().getProperty("weblogic.system.home") +
              > > > java.io.File.separator + propertiesName;
              > > > props =
              > > > props.load(new DataInputStream(new FileInputStream(location)));
              > > >
              > > > ****************************
              > > >
              > > >
              > > >
              > > >
              > > > Thanks in advance
              > > > Ravi
              > > >
              >
              

  • How to use properties file

    Hi,
    I want to use properties file in my application. I have kept properties file inside a directory called properties which is inside myProject(which is the parent directory of my project) i.e "myProject/properties".
    My java file where i want to call this properties file is inside the myProject/WEB-INF/src/java.
    How can i call the properties file from myProject/WEB-INF/src/java/PropertyReader.java
    I wrote java program in myProject/WEB-INF/src/java/PropertyReader.java like:::::
    ResourceBundle resBun = ResourceBundle.getBundle("Test", Locale.getDefault()); // Test.properties is inside myProject/properties
    resBun..getString("name");
    After running the program i am getting the following errors:::::
    Exception in thread "main" java.util.MissingResourceException: Can't find bundle for base name Test, locale en_US
    at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:836)
    at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:805)
    at java.util.ResourceBundle.getBundle(ResourceBundle.java:576)
    at PropertiesReader.main(PropertiesReader.java:4)
    What is the issue? How to use properties file?
    Waiting for reply.
    Thanks

    Still getting same exception. As you explained i tried like the below:::
    1. I am using ant as build tool.
    2. My properties file is for database configuration
    My properties file is::
    database.properties (inside myProject/properties)
    JDBCDriver=org.gjt.mm.mysql.Driver
    JDBCConnectionURL=jdbc:mysql://pmdbmysql:3306/bandwidthshaper?user=admin&password=admin
    My java package structure is
    WEB-INF/src/java
    WEB-INF/src/classes
    For build WEB-INF is the base directory and build.xml is inside the src directory
    In my build.xml i wrote the following lines for compilation::
              <target name="compile" >
                   <javac srcdir="src" destdir="src/classes" debug="true" debuglevel="lines,vars,source">
                        <classpath refid="class.path"/>
                   </javac>
    <copy todir = "src/classes" >
    <fileset dir = "../properties" />
    </copy>
                   <jar jarfile="lib/${project.jar.file}" basedir="src/classes"/>
              </target>
    I am copying properties file to the classes directory.
    Now in java file which is inside /WEB-INF/src/java, I wrote::
    try {
    Properties programProps = new Properties();
    InputStream is = getClass().getResourceAsStream("/database.properties");
    if(is == null)
    throw new IllegalStateException("Properties file missing ");
    programProps.load(is);
    System.out.println("driver name::::::: "+programProps.getProperty("JDBCDriver"));
    is.close();
    } catch(Exception e) {
    e.printStackTrace();
    After compilation in my classes directory i am getting database.properties file and my java file with package.
    At the time of running i am getting "java.lang.IllegalStateException: Properties file missing"
    Now tell me where is the fault. Why again i am getting exception.
    Thanks

  • Help with best solution for file read/write in web app (not local files)

    Problem in a nutshell...
    I have an AIR app to process images..  organize and add information. This information is read and written to local XML files. This is working fine (if still a be messy... still learning this OOP stuff ;O)
    So... now I am developing my Web gallery app to consume these files for a web gallery (unique concept huh? ;O)
    Reading them in was easy with the Declaration block....
    <fx:Declarations>
    <fx:XML id="galleryXML" source="gaXML.xml"/>
    <fx:XML id="baXML" source="baXML.xml"/>
    <fx:XML id="prjXML" source="prjXML.xml"/>
    <s:XMLListCollection id="galleryList" source="{galleryXML.item}"/>
    <s:XMLListCollection id="baList" source="{baXML.item}"/>
    </fx:Declarations>
    But I want the owner to have a maintenance mode where information can be added/changed and saved back to the XML file on the server. I have read about all the different services available, but I am not that familiar with them. Also I will have no way of knowing what services the user will have available on their host. So... help me out in understanding what the most universal solution would be to be able to read and write XML files stored on the host along with the application.
    I hope that is clear enough, but ask away if any more details will help in the discussion.
    Thanks
    Bob Galka

    Hi Jeba,
    Whenever u are using *"Thread.currentThread().getContextClassLoader()"* Code inside your application means the Files (Resources) which you are looking right now must be poresent in the CLASSPATH...(Bootstrap classloader/ System ClassLoader/ Application ClassLoader/ Sub Module ClassLoader...).
    So when we place a resource (example XML or Properties file) inside the "WEB-INF/classes" directory then it means that file (resource) is available as part of the Module Classloader....So the above code getContextClassloader() will be able to find that resource easily.
    Thanks
    jay SenSharma
    http://middlewaremagic.com/weblogic (Middleware Magic Is Here)

  • Loading the wrong messages properties files

    Hi
    I'm using myfaces implementation version 1.1.3 with JBoss-4.0.3 (Tomcat 5.5).
    I have a single .ear file, containing several .war and .jar files. My main application is foo.jar, and I have several web archives, say foo_a.war and foo_b.war for example.
    Both these web archives are referenced in application.xml correct (i.e. both have a different web-uri and context-root elements).
    Both foo_a.war and[i] foo_b.war have properties files under their WEB-INF folder, with the same names (say messages_en.properties for example). However I have different values for the same keys in these properties files.
    For example, I have a label called 'product_name', appearing in both messages_en.properties files.
    Under foo_a.war it is:
    product_name=foowhile under foo_b.war it is
    product_name=barThe problem I'm experiencing is that although I'm approaching the URL of foo_b, I still see the product name of foo_a. It appears as if my application does not recognize the properties files of foo_b.war.
    However, when I don't deploy foo_a.war - I see the correct text.
    Did anyone ever encounter such a problem? Am I configuring something wrong?
    10x

    Hi
    I'm using myfaces implementation version 1.1.3 with JBoss-4.0.3 (Tomcat 5.5).
    I have a single .ear file, containing several .war and .jar files. My main application is foo.jar, and I have several web archives, say foo_a.war and foo_b.war for example.
    Both these web archives are referenced in application.xml correct (i.e. both have a different web-uri and context-root elements).
    Both foo_a.war and[i] foo_b.war have properties files under their WEB-INF folder, with the same names (say messages_en.properties for example). However I have different values for the same keys in these properties files.
    For example, I have a label called 'product_name', appearing in both messages_en.properties files.
    Under foo_a.war it is:
    product_name=foowhile under foo_b.war it is
    product_name=barThe problem I'm experiencing is that although I'm approaching the URL of foo_b, I still see the product name of foo_a. It appears as if my application does not recognize the properties files of foo_b.war.
    However, when I don't deploy foo_a.war - I see the correct text.
    Did anyone ever encounter such a problem? Am I configuring something wrong?
    10x

Maybe you are looking for