• Post Reply Bookmark Topic Watch Topic
  • New Topic

Capturing Application Version on JSP

 
Gobind Singh
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a link on every page of my web app called "About". Clicking on this link brings up a pop up which shows the details of all the developers who contributed to the development of this webapp.

I want to be able to show the version of the webapp too. The only thing is that the version changes each time a deployment is done.

One possible option is let the ant build script modify the about.jsp file (at build time) that shows the version number by doing a token replace using the version number from the repository (SVN).

But that would mean that the about.jsp has changed and I have to check it into the version control system again.

I dont want to do this. Is there anyway I can read the version information from the Manfiest file in the war and show it on the JSP?
 
Sunil Vasudevan
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you keep the version in web.xml, you can update it as and when you need. But it would need restarting the server and in some cases, if your web-app server does not allow you to update the web.xml packaged in a war file, then you need to repackage after making the update.

A better solution could be to push this information in database or have a properties file/LDAP to handle this. In this way, you need not make any changes to the war file.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65522
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sunil Vasudevan:
A better solution could be to push this information in database ...


Thereby practically guaranteeing that they'll get out of sync at some point.

The version should be part of the app, should be part of the build and source control, and should be part of a re-deploy.
 
Gobind Singh
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok guys you have confused me. All I want to be able to do is read something in the WARs Manifest.MF file and display it on the JSP.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do this by putting a token in each source file in the application
"|||RELEASE|||" I have my ANT build script replace that token with the build number.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65522
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There may be Java API in the jar/zip handing utility classes that can help you read a manifest, but that sounds like a lot of work.

What I do is to have the ant script build a properties file with all the build and version info. This properties file is placed in WEB-INF and read by a context listener which loads a Map with all the properties it finds in the file and places it in the app context where it available to every resource in the web application.

Using a database or other external storage for the version info is doomed to failure as there is nothing to ensure that the app and the database info are kept in sync. Making it part of the build does.

I'm not sure what your beef with checking things into SVN is -- that's what version control systems are for. I not only check the version information in, but for deployed versions I create an SVN tag so that the release is easily recreated. If you're not checking the version info into source control, you are losing that information and making it harder to keep track of the app's revisions.
[ May 08, 2007: Message edited by: Bear Bibeault ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!