Results 1 to 6 of 6

Thread: Getting html element names from a file outside the war

  1. #1
    Join Date
    Jan 2012
    Posts
    2

    Post Getting html element names from a file outside the war

    What is the best way to get html element names from a file (.properties) outside the war?

    We have different environments where different fields, drop-down options, check boxes will have different text.
    Ex.
    Env1
    Point : (input box)
    Location: (drop-down)
    loc1
    loc2
    loc3


    Env2
    BBOX: (input box)
    Location : (drop-down)
    loc4
    loc5
    loc6

    So we would have a separate property file for each environment.

    Can I use the messages.properties and then do:
    <fmt:message key="menu.loc"/> for the element in the jsp
    And then have the messages.properties outside the war?

    in the servlet-context.xml:
    <bean id="messageSource" class="org.springframework.context.support.Reloada bleResourceBundleMessageSource">
    <property name="basename" value="somewhere outside the war" />
    </bean>

    Or is there a better way?

    Thanks!
    Last edited by msimonian77; Jan 31st, 2012 at 06:11 PM.

  2. #2

    Default

    You can put the location of your properties file onto the server classpath and you should be able to access it using

    Code:
    <bean id="messageSource" class="org.springframework.context.support.Reloada bleResourceBundleMessageSource">
         <property name="basename" value="classpath: nameOfPropertiesFile" />
    </bean>
    If you are using Websphere, you can setup a "Shared Library" in the admin console that points to a folder, this will add it to your server classpath.

    Another (better IMHO) way would be to use a build tool like Maven. Using profiles in Maven, you are able to define all the entries in your properties files as variables. When you build for a specific environment, Maven will write the environment specific values into your properties file. That way you will have only 1 properties file for each environment (although you will have a separate ear/war for each environment).

    hope that helps.

  3. #3
    Join Date
    Jan 2012
    Posts
    2

    Default

    Thanks for the fast reply!

    We can't use the maven solution as we only build in one environment.
    We prefer to have like a property file outside the war that we can easily modify when we deploy to the other environment.
    We are using Tomcat 7 as our server.

    Please let me know if the solution I mentioned above is the best one or if there is something better.

    Thanks!!!

  4. #4
    Join Date
    Feb 2012
    Posts
    2

    Default

    Quote Originally Posted by knoxor View Post
    You can put the location of your properties file onto the server classpath and you should be able to access it using

    Code:
    <bean id="messageSource" class="org.springframework.context.support.Reloada bleResourceBundleMessageSource">
         <property name="basename" value="classpath: nameOfPropertiesFile" />
    </bean>
    If you are using Websphere, you can setup a "Shared Library" in the admin console that points to a folder, this will add it to your server classpath.

    Another (better IMHO) way would be to use a build tool like Maven. Using profiles in Maven, you are able to define all the entries in your properties files as variables. When you build for a specific environment, Maven will write the environment specific values into your properties file. That way you will have only 1 properties file for each environment (although you will have a separate ear/war for each environment).

    hope that helps.


    We can't use the maven solution as we only build in one environment.
    We prefer to have like a property file outside the war that we can easily modify when we deploy to the other environment.
    We are using Tomcat 7 as our server.


    ___________________________________

    wholesale jerseys
    nike nfl jerseys
    Cheap Pro Jerseys

  5. #5

    Default

    Have you tried to add the properties file to Tomcat's lib directory. Your app should be able to pick that up as it's in the CLASSPATH.

  6. #6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •