Thursday, January 05, 2012

Access a properties file from JSP/JSTL EL

Sometimes you need to show information in a JSP from a properties file. Typical scenario is configuration data.

With spring you could do:


Then from a Listener or even from a Controller you could Autowire and inject the variable as a context or request attribute respectively:
...
@Autowired
public Properties applicationProperties;
...
request.setAttribute("applicationProperties", applicationProperties);

Suppose app.properties has this content:
...
bhub.environment=LOCAL
...

Then from JSP/JSTL you can use it as:

No comments:

Followers