Announcement Announcement Module
Collapse
No announcement yet.
Can one use .properties variables in web.xml file? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Can one use .properties variables in web.xml file?

    I have a web application with a PropertyPlaceholderConfigurer that fetches properties from a somefile.properties.

    In web.xml I have:

    Code:
    	<context-param>
    		<param-name>contextConfigLocation</param-name>
    		<param-value>classpath*:applicationContext*.xml</param-value>
    	</context-param>
    
    	<listener>
    		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    	</listener>

    I was trying to set up this web.xml element:
    Code:
    	<session-config>
    		<session-timeout>${some.property}</session-timeout>
    	</session-config>
    where some.property is in my somefile.properties. However, this doesn't resolve. My question is: is it possible to use placeholder properties in web.xml ? If so, how?

    Thank you for the help!

  • #2
    this post will help you resolve your problem
    http://stackoverflow.com/questions/2...ith-contextcon

    Comment


    • #3
      Originally posted by vishnu.joshi View Post
      this post will help you resolve your problem
      http://stackoverflow.com/questions/2...ith-contextcon
      I don't think it's the same. That link talks about "defining which properties file to use in web.xml", not about setting web.xml elements to values defined in a properties file.

      Comment


      • #4
        It isn't possible, spring will only use the properties to replace values in applicationcontexts not in other files.

        Comment


        • #5
          Yes you are right its not the same. If you want to access the values of a property file in web.xml then i think it won't be possible. As the app server or web server reads the web.xml and they provide no such support.

          If you want to set the session timeout using property file then a work around could be using a HttpSessionListener. In the sessionCreated() method, you can set the session timeout using your property file value.

          Comment


          • #6
            I suggest using a listener to set the session timeout (or other j2ee properties) programmatically reading the values from a properties file at the start of the application.

            Comment


            • #7
              Hi vishnu.joshi. Thank for sharing link. It helps me, too.

              Comment

              Working...
              X