Externalizing the Properties file in JSF

Hi,
I want to access a properties file located in "C:\" drive in JSF.
In case if i move the file to some "D:\" location, only changing its path
should work for me. Is there anyway of externalizing the properties file
rather than keeping it in WEB-INF?
Thanks in advance

It depends on how the code is written.
I assume you're calling the files using the ResourceBundle.getResourceBundle method: if you do this during the initialization (server startup) you need just to restart the ejb module to make it re-read the files.
I'm quite in a similar situation (WAS4, lots of .properties)and every time I make some changes to my files I need to restart the applications in order to make them read such modifications.
In no case you should redeploy the ejb module (if this is the case, there must be something wrong somewhere else...)
bye

Similar Messages

  • How to read the properties file available in Server File structure in webdy

    hi all,
    I have developed one webdynpro application. In this application i need to access mdm server to continue. For getting the connection i need to pass the IP addresses.
    Can i have code  how to read the properties file which is residing in the server file. with out included along with the application. keeping some where in the file structure in the server. I want to read that properties file by  maintain the iP addresses and users in  properties file based on the key i want to read like below.
    servername="abcServer"
    username="john"
    password="test123"
    Please send me the code how to read this properties file from the file structure and how to read this values by key  in webdynpro application
    Regards
    Vijay

    Hi Vijay,
    You can try this piece of code too:
    Properties props = new Properties();
    //try retrieve data from file
    //catch exception in case properties file does not exist
    try {
             props.load(new FileInputStream("c:\property\Test.properties")); //File location
             String serverName = props.getProperty("servername"); //Similarly, you can access the other properties
             if(serverName==null)
               //....do appropriate handling
         }     catch(IOException e)
                   e.printStackTrace();
    Regards,
    Alka.

  • Problem storing special characters (\, \n etc.) in the Properties file

    Hello,
    I am trying to store a string that contains special characters like \, \n, which are normally escaped using a \ character. If I try to save the Properties object into a file (using the store() method call), it doesn't store these escape characters as they are. The following is what I am trying to do:
    Properties p = new Properties();
    String samp = "This string will have a \\ and a newline \ncharacter";
    p.setProperty( "sample", samp );
    p.store( new FileOutputStream( "/path/to/my/file" ) );I am trying to achieve the following result:
    sample=This string will have a \ and a newline
    characterBut, instead, I get this:
    sample=This string will have a \\ and a newline \\\ncharacterCan somebody help me with this problem?
    Thanks,

    Thanks for your replies and efforts to help me out. I
    guess there is no solution to my unique problem.
    Basically I need this because one of my values (for a
    key) is a multi-line value. It will probably load
    fine when I use the \ character to delimit multiple
    lines, but when I want to write back the same value
    as multiple lines (using \ and \n characters), I am
    unable to do that. I don't follow, or else if you're saying what I think you are, I disagree.
    Let's say you have a String in your program that contains some \n characters, so if you print that string, say with println, on a Unix terminal, you'll see it on separate lines.
    Now you write that string out to a properties file with store().
    Forget how it looks in the props file. Consider that opaque, a black box.
    Now you use load() to get it back from the properties file. It will be re-created in its original form, so if you print it out on a unix terminal, you'll again see multiple lines. The fact that it's all on one line in the .properties file doesn't affect that.
    Now, if you want it to appear on multiple lines in the props file, then we're back to my previous post--you're breaking the format that load expects.
    At least, that's my understanding of how it works. I might be mistaken, but I think I've tested this very thing in the not-too-distant past.

  • How can i locate the properties files within a ejb container?

    when i develop servlet+javabean structure application,in order to imploement decoupling,i
    would like to write the config information in the properties files(key-value pair),in
    servlet,i use "getResourceAsStream(String relativePath)" method to retrieve the
    configuration information from the properties files(i even write the SQL clause
    in the files),it alwsys works well.
    now,i want to implement such function within the ejb container,that is to read
    a properties file from session bean,but i don't know how can i locate the file
    within the ejb container by using relative path,i wonder if there is the same
    method within ejb container as "getResourceAsStream(.......)" method within servlet
    container?
    thanks for any helps!
    the code snippet is appreciated!

    In general, you should look at using environment entries (variables) in the
    deployment descriptors (both the war and EJB jar rather than properties
    files for configuring J2EE applications. The reasons for this are many:
    1. This is the official way to do it according to the spec. Properties
    files are the J2SE way of doing things
    2. As you note, that it's not obvious how you would (legally) read a
    properties file inside an EJB.
    3. It's consistent between the web and EJB part of your code
    4. the weblogic console and tools have good capabilities to edit these
    fields.
    Kent
    "zhebincong" <[email protected]> wrote in message
    news:[email protected]..
    >
    when i develop servlet+javabean structure application,in order toimploement decoupling,i
    would like to write the config information in the propertiesfiles(key-value pair),in
    servlet,i use "getResourceAsStream(String relativePath)" method toretrieve the
    configuration information from the properties files(i even write the SQLclause
    in the files),it alwsys works well.
    now,i want to implement such function within the ejb container,that is toread
    a properties file from session bean,but i don't know how can i locate thefile
    within the ejb container by using relative path,i wonder if there is thesame
    method within ejb container as "getResourceAsStream(.......)" methodwithin servlet
    container?
    thanks for any helps!
    the code snippet is appreciated!

  • Where does the properties file go?

    Hi Folks!
    I'm trying to load a system properties file (myproperties.txt) using the example in java.sun.com. I just want to know where the properties file goes.
    The example is as follows:
    =========================
    import java.io.FileInputStream;
    import java.util.Properties;
    public class PropertiesTest {
    public static void main(String[] args) throws Exception {
    // set up new properties object
         // from file "myProperties.txt"
    FileInputStream propFile = new FileInputStream("myProperties.txt");
    Properties p = new Properties(System.getProperties());
    p.load(propFile);
    // set the system properties
    System.setProperties(p);
         // display new properties
    System.getProperties().list(System.out);
    =======================
    Could someone tell me where the file should physically reside (C:\..\..\).
    Also, is it possible to get the path dynamically by using getRealPath() instead of hard coding the file path in the code..
    Thanks for your assistance!
    Dranim

    The properties file goes where you want it to go. Just make sure you give it the full path.
    To make it dynamic, just make it a parameter.
    java myProg "c:\\temp\\MyProp.txt"

  • Where to put the properties file

    I am a new user of NetBeans6.0, I am making a simple application for user registration. I have coded everything but when I run project I get error caused by the dao.properties file load problem.
    I have put the dao.properties file inside the classes directory(where all java class files are build after running the project) of my web application directory( I didn't create this directory though, it is automatically created by IDE), I think there is a problem with its path.
    where should I put the dao.properties file so that when I run the project the Tomcat automatically find it and also, what the settings I should do?
    actually, I have referred to BalusC'd  DAO tutorial: the data layer but that comes in use when we are working off the IDEs, In my case since I am using Netbeans so it may be different from that one.
    if someone already done that then please let me know

    ok, but will it work if I upload the project in a remote host?
    lets talk besides IDE, as in your DAO tutorial you have instructed to put the properties file somewhere in root of the classpaths. ok, it will work on a local computer cause there is classpath setting but since remote host doesn't know about that property file and we cant set classpath at remote host(I am not sure though if we can) then how will it work at remote host.
    how the server at remote host comes to know about that property file?
    In my case since I have made the project using IDE and everything regarding classpaths have been set automatically(IDE done itself), but at remote host these sort of settings are not done then how the project will run?
    if I have described my problem incorrectly then please consider it as it is supposed to be.

  • To Read the contents of the properties file which is located in webserver

    Hi,
    I have one requirement where I have to read the contents of a property file which is located in some path in server. Say for example, when you click on link abcd then contents of abcd.properties file should be displayed in one text view in webdynpro . I am trying to implement this in webdynpro for java. The main thing is like I am not able to retrieve the server path of the file and hence not getting the file contents. I tried using methods like  getApplicationPath() or getRealPath() but its not working. So can you guys please help me on to how to read the server file contents.
    Thanks and regards,
    Sai

    Hi Romano,
    Thanks a lot for your reply. However, I forgot to mention one thing in my question. Its like the path will be different everytime. Say, we have systems like development, acceptance, production. So when the user clicks on the link abcd, it should take the path of development system and similarly when the user clicks on the link in acceptance or production, the path will be different. say for example, in development the path will be
    usr/cluster/dev/abcd.properties but it acceptance it will be usr/cluster/acc/abcd.properties. So just want to know whether this will work? Anyway, I will give this a try.
    Thanks once again,
    Sai

  • Weblogic Classpath setting error not able to pick the properties file

    Hi All,
    We are using a third party jar and create a java Web service on the top of that jar. This jar file need two configuration file .properties and .xml when we deploy war for the application into weblogic server it will give file not found error. Though this file already exists inside the .war but from the application it is not able to pick the files.
    We find that these file need to be put in weblogic domain home and we put it there and application works.
    I decompile the jar and found that inside java class they use FileReader("allXXX.xml") path and when I Google it and found that it will pick the file from weblogic domain directory.
    The issue is that we need to put properties file in specific weblogic folder like /3party/config by setting the class path inside startWebLogic.cmd. Please let us know solution for same
    Thanks in advance
    Edited by: sb**** on Mar 19, 2012 9:08 AM

    Hi , I am also facing the similer issue. I am deploying war file of my Spring MVC application , but its not picking resource bundle .properties files from one of the configuration file.
    <bean id="PropertiesRepository"
              class="LanguageBasedPropertiesRepository">
              <property name="propertiesFiles">
                   <map>
                        <entry key="en" value="classpath:/exceptionMessages.properties" />
                        <entry key="es" value="classpath:/exceptionMessages_es.properties" />
                        <entry key="default" value="classpath:/exceptionMessages.properties" />
                   </map>
              </property>
         </bean>
    Please let me know how we can modify this to make it work.
    thanks .

  • Convertion of the properties file

    Hi,
    Does any one knows, how to convert the WLS 5.1 properties file to WLS 6.0 version. i cannot see the convert link on the default console that comes up.
    Thanks,

    Something to that effect at least. :) Don't have the code in front of me, but figured you would get the idea, as obviously there is more to code, especially if you want to put getting of resource items in a separate class like I did.
    import java.util.MissingResourceException;
    import java.util.ResourceBundle;
    public class PropertyParser {
         public static final String VERSION = "1.0";
         PropertyParser() {
              super();
          * @param res     Properties file name
          * @param key     Property key
          * @return string value of the requested property
         public static String getString(String res, String key) {
              try {
                   return ResourceBundle.getBundle(res.trim()).getString(key.trim());
              } catch (MissingResourceException e) {
                   return '!' + key + '!';
    }Just took the auto generated class when you externalize strings to .properties file and customized a bit.
    This way I can use one call to get any property from any file I have in classpath (e.g. PropertyParser.getString("file1","key") or PropertyParser.getString("file2","key")).
    Hope that helps.

  • Have been lost, all the properties files in the CM repository (FSDB mode)

    Hi,
    I encountered the following problem: lost all descriptions to folders and files in the CM repository, which is connected to the FSDB mode. This happened as follows. At desired time connection to the server where the repository was broken, after some time the link was restored, but the repository was not available. After this portal has been restarted, and the repository to work, but lost all completed file properties, including the description.
    How do I return all the description files?

    Hi Stanislav,
    Has this issue been resolved?
    If not then the only way to restore this lost metadata would be a be restore, see sap notes 900571 and 737877 for more details.
    Regards,
    Lorcan.

  • Is it possible to reference environment variables in the .properties files?

    Here’s what I’d like to do…
    In the application.properties files, I tell OPA where the docgen server is via this setting:
    # Location of the Document Generation Server
    plugin.docgen.server.url=http://bipDev/document-generation-server/
    Note that this is the setting from my Dev environment.
    Because I have separate DocGen servers for each environment, I have to maintain separate copies of this file for each environment. For example, my Prod file contains this setting:
    # Location of the Document Generation Server
    plugin.docgen.server.url=http://bipPrd/document-generation-server/
    Notice that it’s a very slight changes. I’d like to use something like this instead:
    # Location of the Document Generation Server
    plugin.docgen.server.url=http://%BIP_SERVER%/document-generation-server/
    Obviously, I’d create an environment variable on each server to accommodate the setting. For example, on my Prod machine, I’d create this environment variable:
    BIP_SERVER = bipPrd

    Unfortunately environment variables cannot be used in the OPA .properties files. The only way to do this is to maintain separate properties for your different environments.

  • Text editor used to type the contents of the properties file

    ******To all those (expect iainsinclair) who view this message - Sorry for using this forum for my personal contacts **********
    Hi iainsinclair
    Thanx for explaining ur experience to me for my previous posted topic . U did mentioned a text editor called NETBEANS PROPERTY TEXT EDITOR .
    * Can u please explain more about this editor . Is this editor specific to some encodings ....
    * U said that as u enter the Japanese characters in ur keyboard the editor saves the characters in the unicode format. Are the characters displayed in their glyphs or as \u????.
    * Can u give me a list of languages f or which this text editor can be used . Bcoz u had suggested that it can be used for chinese also .
    * I need more info about a Japanese Computer and keyboard. I think we both are in the same level in this topic I18N . Iam working for I18N project in my company. This is my official mail ID- [email protected] .Can u send me ur mail Id so that we make sure that this forum members are not disturbed by our discussion .

    Hi, I'm happy if I can help.
    * Can u please explain more about this editor . Is this editor specific to some encodings ....
    It's the netbeans IDE from www.netbeans.org it's a free integrated development environment for java. It includes many editors, for .java files, .properties files and many others. It is designed to accept text in the non-ascii format and convert it for use in properties files.
    * U said that as u enter the Japanese characters in ur keyboard the editor saves the characters in the unicode format. Are the characters displayed in their glyphs or as \u????.
    They are saved as ascii characters, not glyphs. For example, I entered MSGothic (MS&#12468;&#12471;&#12483;&#12463;) in japanese using net beans and it looks like this when I use a normal text editor: MS\u30B4\u30B7\u30C3\u30AF
    * Can u give me a list of languages f or which this text editor can be used . Bcoz u had suggested that it can be used for chinese also .
    It should work for any language that your windows/linux system has support for (need the right fonts for a start). My system is native japanese, so I have all the required japanese fonts installed. If you want to use (for example) Chinese on an English system, you'll have to get the fonts and probably you will need to modify the jre/lib/font.properties file.
    * I need more info about a Japanese Computer and keyboard. I think we both are in the same level in this topic I18N . Iam working for I18N project in my company. This is my official mail ID- [email protected] .Can u send me ur mail Id so that we make sure that this forum members are not disturbed by our discussion .
    I don't think it's disturbing anyone. Forums are all about sharing information, and there is a lack of experience of I18N in the broader comminity, I feel. This isn't a busy forum... ;-)
    Don't forget to look for the article written by John O'Conner called 'Displaying Text' I don't have the URL handy but it was posted on this forum recently. It's required reading.

  • Html tags in .properties files.

    Hi all,
    I want a small clarification regarding the .properties file in JSF.
    I want to execute html tags in the properties file. my resource file is...
    code = Section Code
    I want to make the Section Code as bold. If i give like this
    code = < b > Section Code < /b >
    all the html tags are displayed as it is on UI. In struts this works fine. means "Section Code" is displayed in Bold.
    In JSF, is there any way to do this?
    Thanks.

    Use escape attribute of outputText tag.
    <h:outputText value="#{employee.dataText}" escape="false"/>

  • How to read JBoss server 'app.properties' file in the deployed Flex application?

    Hi, my current Flex project is using LCDS server to make call (Remote object call and Data managements services' call) to the backend Java services and consume data to render. I have defined the AMF and RTMP channels in the services-config.xml file and destinations for the Java services' in the remoting-config.xml and data-management-config.xml files.
         <channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
                <endpoint url="http://localhost:8080/eqcFlex/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint"/>
                <properties>
                    <polling-enabled>false</polling-enabled>
                </properties>
         </channel-definition>
    As of now both the Flex application WAR file and Java services EAR files are depolyed on the JBoss server on my machine, therefore I can hardcode the endpoint URL as http://localhost:8080 in the services-config file and hit the Java services.
    But the requirement is that the Flex application WAR file needs to be deployed on JBoss servers deployed on different machines and hence the endpoint URL cann't be hardcoded in the services-config.xml file. Is there a way we can pick up the endpoint URL from the JBoss server's app.properties file so that we can dynamically create channels in Actionscript code and make call to the backend services with dynamic endpoint URL?

    But in Command prompt I found out that My properties file by name
    'cedrelay.properties' is not recognised by web.xml.My web.xml structure is
    How does web.xml "recognize" anything?
    You specify the properties file as an init parameter. Do you read it in the init method of the servlet? If so, what does the code look like for reading the properties file?
    You'll have better luck if you put that properties file in WEB-INF/classes and load it as a resource input stream from the CLASSPATH.
    %

  • "The system cannot find the file specified" - error reading properties file

    I have packaged a class file and a .properties file in the same folder as a ejb-jar file and in the class file i try reading the properties file and it throws me the error - "The system cannot find the file specified". But when I put the complete path, it has no problem finding the file.
    I know that this must be the problem with classpath, but can anybody tell me why it is not finding the properties file even if they are in the same folder. How do I make class files find .properties file which are in a folder.
    Any help will be greatly appreciated.

    Hi,
    I am not sure if your question is realted to the Oracle Application Server - anyway, if you are packaging a class file and a properties file in a JAR File, you need to read the contents in a different manner...something like this... :
    URL url = new URL("jar:file:/home/duke/duke.jar!/");
    JarURLConnection jarConnection = (JarURLConnection)url.openConnection();
    You might want to have a look at this link for more information :
    http://java.sun.com/docs/books/tutorial/index.html
    You may also get better responses if you post your question in one of the Java Forums.
    Regards,
    Sandeep

Maybe you are looking for

  • How I successfully upgraded from iPhoto '09 to iPhoto '11 - Glitch Free.

    I've been eagerly reading the forums PRIOR to installing iPhoto '11 and I'm about to dive in. I have an iMac 2.8 GHz Intel Core 2 Duo with 6GB RAM running Snow Leopard OS X 10.6.4. I'm currently running iPhoto '09 (version 8.1.2) with 1403 events, 41

  • Safari won't open BBC!

    Hi, I've had my Macbook for a couple of weeks and everything was excellent until yesterday. I always read news from the BBC (www.bbc.co.uk) and now I cannot open the page. I get the following message: "Safari can't open the page "http://news.bbc.co.u

  • How to get an Apple USB Superdrive to be recognized in Windows 7 VM

    Hello, I have just installed Win 7 VM under FMWare Fusion 7.x, and cannot get Windows to recognize the USB external Superdrive.  I go up under Virtual Machine and click to connect, it says it will and do I want it to always do this?  I click YES.  An

  • Adding scripts to Actions

    I am involved in a lot of works of handling thousands of photos (digital/scanned, B/W as well as color, of different ages: I have to treat images from '30s) and in my workflow (Bridge-Camera Raw-PSHP) I have a lot of repetitive actions to take. One v

  • Urgent for know my ipad is using, but my icloud cant search?

    Hi all of you, my ipad now is using to download the music but i use my iphone to "find my iphone" the apps are not taking any route, i have do the activate lock and play sound on my ipad but is offline, The people is still dont know my icloud is sett