Announcement Announcement Module
No announcement yet.
Read the Properties values in JSP Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Read the Properties values in JSP

    I am running a java web application on Java 6 and Spring 3.0.

    I have properties file used by the web application and is loaded by the spring framework on server start.
    I have requirement to use the properties values in java and jsp code. I am able to access the value in java using annotations provided in spring 3.0 : @Value("${test.url}")

    To use the properties in JSP, I am trying to load the properties into servlet context, so that the properties can be referenced in the JSP directly

    servletContext.setAttribute("props", properties);

    In my jsp, when i print ${props}, it results the following ...


    But when i print ${props.test.url}, it prints nothing (the same works for ${props.url}).

    Is this an issue or am i doing something wrong. How can i get the ${props.test.url} work in jsp

  • #2
    Put it in quotes

    The problem is EL first tries to look for a property called "test" on props, which is a map, so it fails resolve.
    If it found a property called 'test', it would then try and resolve a property called 'url' on that object.
    It can't interpret 'test.url' on its own.


    Last edited by nostradamus; May 24th, 2012, 01:29 AM.


    • #3
      How do we get access to the properties map in JSPs rendered by the web flow?
      The properties map always seems to be null.
      (It's not null if the JSP is rendered using traditional spring MVC)