October 2, 2008

Displaying Maven POM Version in a JSP

So in most web apps you want to know what version is deployed to the server and with maven that is easy. When maven builds a war file it creates a in the war's META-INF/ directory in the following format "META-INF/maven///"

Here is how to read that file and display the version of the pom on a jsp page...

<%@ page import="java.util.*"%>
<% in = getServletContext().getResourceAsStream("META-INF/maven/groupid/artifactid/");
    Properties mProps = new Properties();
    String mainVer = (String) mProps.get("version");

App Version: <%= mainVer %>


  1. Exactly what I was after. Thanks

  2. I've managed to read from inside the war-file containing the jsp. But I want to read from ALL wars deployed in the same container.

  3. Hello,
    Thanks for this usefull post.

    I would just point out that, if you JSP is not directly under root context, you should prefix it by / your ressource URI : in = getServletContext().getResourceAsStream("/META-INF/maven/groupid/artifactid/");