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,

Similar Messages

  • Use properties file in Struts framework

    I develop a websit with struts, web ap is tomcat5.0, and I have a conf.properties file
    this file is different from ApplicationResource.properties, conf.properties in the /MySite/conf/ directory, not in src directory
    When I Use the conf.properties file in a Common Java Class that not extends any super class
    it will occur a FileNotFoundException exception
    How to make it
    public class Environment
         private static Properties prop = new Properties();
         private static FileInputStream in = null;
         public static String getVariable(String key)
              try
                   in = new FileInputStream(new File("\\conf\\config.properties"));
                   prop.load(in);
                   return prop.getProperty(key, null);
              catch (Exception e)
                   e.printStackTrace();
                   return null;
              finally
                   try
                        in.close();     
                   catch(Exception e)
                        e.printStackTrace();
         }

    Your class cannot find the file in the location tht u have given. The path (\\conf\\config.properties) is relative to the location where your source (Environment class) is kept.
    Try to hard code the path & see if your source can find the prop file ...

  • 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.

  • Can i have multiple ActionServlet in a struts framework?

    Can i have multiple ActionServlet in a struts framework?
    if YES then please give me the sample configuration file..
    thanks & Regards
    raghavan

    You can heve multiple actionServlet mappings in struts framework. but it not a good practice to use multiple ActionServlets. It will cause mapping problems later on.

  • Using Search_replace.properties file

    I am trying to use Migration assistant to migrate my forms form 6i to 10g.
    While doing so , I want to use search_replace.properties file to search for soem strings and automatically replace them.
    I want to search for 'message_box(' but it is not being read due to this '(' special symbol.
    How can I include special symbols in search or replace string?

    So no reply on this thread...
    I will take look at jdapi, but with my poor knowledge of java ......
    JeanYves

  • Is it possible to use multiple css files in epub?

    For fixed layout I would like to use multiple css files.
    Is it allowed  by apple requirements?

    Yes. ePub suports multiple CSS files and therefore so does Apple iBooks.

  • File I/O problems using a Properties file

    Hi,
    I am having troubles reading in a properties file. The file looks like this:
    aname=apassword:word2
    bname=bpassword:word
    ...etc
    The code I have this far is:
    import java.util.*;
    import java.io.*;
    public class LoginH
    public static void main(String[] args)
    String logon, pswd;
    //String login = null;
    //String password = null;
    //String nick = null;
    int msg = 0;
    System.out.print ("Login: ");
    logon = MyInput.readString();
    System.out.print ("Password: ");
    pswd = MyInput.readString();
    Properties settings = new Properties();
    try
    FileInputStream sf
    = new FileInputStream("LogonH.ini");
    settings.load(sf);
    catch (FileNotFoundException e) {}
    catch (IOException e) {}
    // public void whitespaceChars(58,58)
    StringTokenizer st = new StringTokenizer(settings.getProperty(logon));
    String password = st.nextToken();
    String nick = st.nextToken();
    System.out.print (password + nick);
    ** It works fine if i replace the colon in my properties file with a blank space, However i need to use a colon. I tried to set whitespaceChar to allow this but I can not seem to get it to work. Let me know if you have any ideas. Thanks in advanced.

    Thanks. I just got done doing something to that nature however now my problem is if the key field is not in my properties file my program crashes. I need to print out to the console "sorry" if my user name which is my key is not in the properties file. Here is my code if anyone can help me out:
    import java.util.*;
    import java.io.*;
    public class LoginH
    public static void main(String[] args)
    //******** Declare Variables *********************
    String userlogin;
    String userpaswd;
    String login = null;
    String paswd = null;
    String nicknm = null;
    int match=0;
    String delim = ":";
    //******** Get username and password **************
    System.out.print ("Login: ");
    userlogin = MyInput.readString();
    System.out.print ("Password: ");
    userpaswd = MyInput.readString();
    Properties settings = new Properties();
    try
    FileInputStream sf = new FileInputStream("LogonH.ini");
    settings.load(sf);
    catch (FileNotFoundException e) {}
    catch (IOException e) {}
    StringTokenizer st = new
    StringTokenizer(settings.getProperty(userlogin),delim);
    paswd = st.nextToken();
    nicknm = st.nextToken();
    if(userpaswd.equals(paswd))
    System.out.println("Ok " + nicknm);
    match = 2;
    else
    System.out.println("Sorry " + nicknm);
    match = 1;
    if (match == 0) System.out.println("Sorry");
    }

  • Use of properties file

    I need to connect to a database I have specified the driver class and url in a .properties file, I have placed this .properties file in the classes folder of WEB-INF
    once i create the war file and sent it to the client, They need to change the url but since we are delivering a war file they cannot do it. How can i achieve this?

    Use a JNDI datasource so that your code doesn't make a connection to the database but uses JNDI to locate the datasource. Then the client only has to create the datasource at the server level and assign it to the JNDI name.

  • How to use JDBC Appender of log4j using a properties file

    Hi,
    I am trying to implement the Log4j JDBC Appender to log the messages to Database(oracle).Can anyone provide me with a sample code along with the properties file used.
    need urgent help.
    Thanks in advance

    Actually, I konw where my problem in my code is. Use functions  
    PDDocAcquirePage(), PDPageGetAnnot(),
    PDTextAnnotGetContents(),
    PDTextAnnotGetContents()
    step by step with the logic designed by ourself can finish my task.
    But also thanks for your help!
     

  • Is this how to use a properties file?

    Hi:
    The following is how I intend to create and read a properties file, please verify for me that the idea is correct.
    1. create myProp.properties
    2. in myProp, the content is like such:
    a=myA
    b=myB
    c=myC
    3. In my application,
      FileInputStream in = new FileInputStream(getClass().getResourceAsStream("/myProp.properties"));
      Properties p = new Properties();
      p.load(in);
      String a = p.getProperty("a");
      String b = p.getProperty("b");
      String c = p.getProperty("c");Thanx!

    It depends on what youare doing but if you have a set of properties that you are going to always use from one running of the application to the next, they should generally be defined as static finals.
    For example, lets say you want a configuration file for an application that holds the user's preferences. You might want something like this:
    public class Preferences {
       private static final String ALWAYS_ON_TOP = "always on top";
       private Properities preferences = new Properties();
       static {
          //load the file
       public boolean setAlwaysOnTop(boolean alwaysOnTop) {
          preferences.put(ALWAYS_ON_TOP, String.valueOf(alwaysOnTop));
       public boolean getAlwaysOnTop() {
          return Boolean.valueOf(preferences.get(ALWAYS_ON_TOP));
       public void save() {
          /save file
    }

  • Use resourceBundle properties file from KM

    Hi,
    I have a properties file called com.mycomp.apps.phonebook.properties in the KM Content of the portal in KM Content => root => mycomp => apps => phonebook => customizing
    Now I'm developing a new LinkCommand service for the UserDetails.
    http://help.sap.com/saphelp_nw04/helpdata/en/65/29b24053c13f5fe10000000a155106/frameset.htm
    The already existing LinkCommand "Send E-mail..." is read from the original resourceBundle com.sap.ip.collaboration.gwui.api.wdf.mail.SendTo
    For my new LinkCommand I would like to use the existing properties file. How do I have to define this file in the uicommand xml or properties xml sheet?
    Can anybody help me?
    With the local project resourceBundle it's working, but I would like to use the file in the KM. Andy ideas?
    Regards,
    Stefan

    Hi Praven,
    Copying all existing SendTo properties file to my project would be an option but I wouldn't win anything.
    I'm quite happy with the existing SAP collaboraton properties files using e.g. for "Send e-mail".
    I won't change this existing ones. I created a new LinkCommand. And for this new LinkCommand I'm looking for a solution how I can handle the translation for it.
    I would prefer e using my existing file which is located in the KM. The reason why it's located in the KM is, if I need to change a translation or add a new translation properties file I only need to change it in the KM. If it's a part of the project I need by every change to deploy the project new.

  • Very weird issue with server logging when using log4j.properties file

    I'm using log4j logging. In log4j.properties the root logger is set up to use the ServerLoggingAppender class so that all our application logs go to the main server logfile. In addition, there are several appenders defined for specific components, with output going to specific per-component log files. Everything is going fine until I launch the server console. At this point all of those per-component log files get wiped out (zero length) and some non-ASCII lines are written to at least one of these files, after which the logs appear to be fine. The main server log file does not appear to be affected (because the root logger is set to "warn" level, while component-specific loggers are set to trace, the contents in these files is different; however I tried disabling all the other appenders and turning the root logger up to trace, and that still did not re-create the problem in the main server log file.
    And here's the really weird part -- if I use the same configuration, but in a log4j.xml file, the problem does not happen.

    Figured it out.
    We were passing in the configuration for log4j as -Dlog4j.configuration=file:/<properties file> and this was added to the command line for both the managed and admin servers. Problem is that the console app starts its own instance of log4j, and when it reads the configuration for the appenders it initializes or rolls over the files. At some point we have two JVMs accessing the same files, so some corruption is bound to happen.
    I'm not clear why the .xml file made a difference, but earlier we had been passing the log4j configuration as a jar file placed in the domain/lib folder, so perhaps the designer reverted to that (placed the log4j.xml file in a jar in lib, and not simply changed the -Dlog4j.configuration=file:/ option.

  • How to use multiple video files??

    hi all,
    i am using flex 4 ...
    now i have designed video player..
    i used single flv file for execution..
    how to use more flv files in tis program???
    i have included program also..
    can any one reply for this...
    thanks in advance...
    regards,
    saran r
    video.mxml:
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:s="library://ns.adobe.com/flex/spark"
                   xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" creationComplete="init()" height="700" >
        <fx:Declarations>
            <!-- Place non-visual elements (e.g., services, value objects) here -->
        </fx:Declarations>
        <fx:Script>
            <![CDATA[
                import mx.core.UIComponent;
                import flash.events.NetStatusEvent;
                import flash.media.Video;
                import flash.net.NetConnection;
                import flash.net.NetStream;
                private var nc:NetConnection;
                private var stream:NetStream;
                public var videoDuration:Number;
                public var nsClient:Object = new Object();
                private var videoComp:Video = new Video();
                private var meta:Object = new Object();
                private var timer:Timer = new Timer(100);
                private var uiComp:UIComponent = new UIComponent();
                private function init():void
                    nc = new NetConnection();
                    nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
                    nc.connect("rtmp://localhost/saran");                 
                    this.addElement(uiComp);
                    uiComp.addChild(videoComp);
                    timer.addEventListener(TimerEvent.TIMER,timerHandler);
                    timer.start();
                private function netStatusHandler(event:NetStatusEvent):void
                    trace("Code ===>>>    "+event.info.code);
                    if(event.info.code == "NetConnection.Connect.Success")
                        connectStream(nc);
                private function connectStream(nc:NetConnection):void {
                    stream = new NetStream(nc);
                    videoComp.attachNetStream(stream);
                    stream.play("Terminator")
                    // stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
                    stream.client = nsClient//new CustomClient();
                    nsClient.onMetaData = metadataHandler;
                    trace("stream ===>>>    "+stream.currentFPS);
                    //responder = new Responder(onResult);
                    // nc.call("getStreamLength", responder, "bikes" );
                private function metadataHandler(metadataObj:Object):void
                    meta = metadataObj;
                    videoComp.width = metadataObj.width;
                    videoComp.height = metadataObj.height;
                    //positionBar.move(videoComp.x, ((videoComp.y + videoComp.height)+20));
                    //positionBar.width = videoComp.width;
                    trace("Duration ====>>>>   "+meta.duration);
                private function timerHandler(event:TimerEvent):void
                    //trace("Timer called.........."+stream.time);
                    //positionBar.setProgress(stream.time, meta.duration);
            ]]>
        </fx:Script>
    </s:Application>

    I have the same question but I am using two pc's

  • Unable to configure log4j using a properties file

    So i have an xml log4j config file that i stole from JBOSS, so i know it has the correct syntax. i put this file into my project dir, and i do this in the main method:
    System.out.println(new File("crawler.log4j.properties.xml").exists()); //prints true
    PropertyConfigurator.configure("crawler.log4j.properties.xml");i have the console appender set to INFO
    I am seeing DEBUG messages.
    i searched my project for log4j* files and there are no other configs laying about.
    what am i missing?

    i should have been using DOMConfigurator instead of PropertyConfigurator

  • Localize app. using Bundle.properties files, need help

    Hi! I used tutorial to internationalize my app.:
    http://www.oracle.com/technology/products/jdev/101/howtos/jsfinter/index.html
    I use Jdeveloper 11g. Have 2 files: LocalizeKokaugi.properties and LocalizeKokaugi_en.properties. My app is internationalized, but when I need to change language then I need use IE or FireFox settings to set language. I have two questions:
    1. What I need to do to change language using my created buttons? Can You give step by step to this?
    2. Can I set VO -> Attributes -> Control Hints -> Labet Text to #{sampleBundle.myTitle}. I tried this, but then the label value don't comes from my bundle. Where is problem and what to do?
    Waiting response from You!
    Best regards

    Deniz Gulmez wrote:
    Hello,
    Is below method enough to change the locale for Application Module also? I am trying to change the locale using the below code. Messages from UI project changes as expected but Entity labels and error messages from Application Module are still in old locale.
    private void switchToLocale(Locale locale)
    FacesContext context = FacesContext.getCurrentInstance();
    UIViewRoot root = context.getViewRoot();
    root.setLocale(locale);
    It should... However I must admit that I rarely push the Locale on the model layer, it does not belongs there, even if ADF encourage that pattern, I highly dislike it and do everything in my power to not have it used in my project. Presentation language is, well, a presentation concern, so should be handled in the presentation layer, not the business one. When the model must send an information, it should be using a code and parameters that then get translated by the view.
    Regards,
    ~ Simon

Maybe you are looking for

  • How do I free up disk space on my MacBook Air

    Hi, I have a MacBook Air with a 128GB disk. I recently noticed that I seemed to be using up 74% of the disk capacity so thought I would try and remove some old video files from iTunes. When deleting the files I was prompted to remove the files from t

  • When I edit, it says it could not complete action because there is not enough memoray(RAM)

    When I am editing in photoshop cs6, a screen pops up that says it could not complete a certain action command because there is not enough memory(RAM).  I have taken my computer to the shop and they put more RAM in.  Not sure what to do anymore?  It i

  • Wrong planned cost calculation while actual is calculating correct for internal activities

    Dear all, I am facing an issue in which when i am doing network costing with work center, activity type, cost center and giving per hour rate in KP26. System is calculating correct actual cost but every time its calculating wrong planned cost. For ex

  • Eewb problem in crm2007 IDES

    Hi:     in the CRM2007 IDES, I used the tcode "eewb" to create a project with a z package, and created a extension, the business object  is  "BUPA" and the extension type is "ADD_NEW_FIELDS" , but the wizard can not start and the error message is "Ex

  • Pretty gtk2 as root, ugly as non-root? [/SOLVED]

    Heh, this is actually a little bit interesting. I've never ran anything that requires X as root until just a few minutes ago and realized that running applications such as pidgin and firefox as root, they are significantly prettier than what it looks