danieltc07
danieltc07

Reputation: 323

Read properties file from jar using jstl setBundle on JSP

All my web app are using a comum JAR file. I'd like to get my framework version, that is into a .properties file, and show it on footer page.

I want to read this properties using jstl setBundle tag.

This is the version.properties file:

deploy_version=1.02
data_deploy=2013/06/04 14\:08
computador_deploy=EG1188930
usuario_deploy=1542069

I'm trying this on my jsp, but I'm getting any value:

<fmt:setBundle basename="br.gov.company.framework.version" var="framework"/>
<fmt:message key="deploy_version" bundle="${framework}"/>

The JAR file is located into \WEB-INF\lib.

Is there another way to get this from JSP? Or do I have to get it from Java getResourceAsStream?

Tnks!

Upvotes: 0

Views: 3772

Answers (1)

JB Nizet
JB Nizet

Reputation: 691635

The properties file is at the root of the jar file. So its basename is not br.gov.company.framework.version, but simply version:

<fmt:setBundle basename="version" var="framework"/>
<fmt:message key="deploy_version" bundle="${framework}"/>

You would use br.gov.company.framework.version as the base name if the path of the file in the jar was /br/gov/company/framework/version.properties

Upvotes: 1

Related Questions