Question

I have a WAR file, and inside a /META-INF/MANIFEST.MF containing my product version info:

Implementation-Version: 1.0.0.0

At my index.jsp I have this code to print the version:

<%  
String version = com.my.Utils.class.getPackage().getImplementationVersion();
out.print("Version: " + version);
%>

This code always return:

Version: 

This solution is based on this article.

What I need to do read my version information from war manifest file?

Was it helpful?

Solution

That article you link specifically mentions the second case, where you're deploying a classic web application:

<%
//Get version of application
java.util.Properties prop = new java.util.Properties();
prop.load(getServletContext().getResourceAsStream("/META-INF/MANIFEST.MF"));
String applVersion = prop.getProperty("Implementation-Version");  
%>
<h2 class="x-panel-header"><%=applVersion%></h2>

The method is different depending on how your application is deployed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top