Announcement Announcement Module
No announcement yet.
JSP Web App configuration the Spring way? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • JSP Web App configuration the Spring way?

    Simple question, but I haven't been able to find a simple answer:

    I'm using Spring, JSP 2.0 and JSTL

    I want to have a configuration parameter for my web application. It will be deployed on various intranets, with different requirements.

    Something like:
    # Can users foo?
    I guess this should go in a properties file, or conceivably it could be in the *-servlet.xml as a bean.

    Then I want a JSP that has something like this:
    <%-- Only display the link if foo is enabled --%>
    <c:if test="${'true'}">
    <a href="...">Foo</a>
    It seems like I want to use EL to access an application property. What is the best way to do this?
    Last edited by jawheeler; Sep 3rd, 2008, 12:50 PM. Reason: Added code tags per Marten's request

  • #2
    Please use [ code][/code ] tags when posting code....

    I would create some configuration object in your applicationContext which holds the properties. Then create a HandlerInterceptor which always adds that configuration object to the request attributes so that it is accessible in the jsp.

    public class ConfigurationAddingHandlerInterceptor extends HandlerInterceptorAdapter {
      private Configuration configuration;
      public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) {
        modelAndView.addObject("configuration", configuration);
    <c:if test="${}">
      //something here