Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Read contextPath during initialization

 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone know of a spec compliant way of determining the contextPath during context initialization?

The only getContextPath method I can find is part of the ServletRequest.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34686
367
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ben,
The only way I can think of is to pass the contextPath in a property file or the like. What are you trying to do with the path? Maybe there is another way.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The middleware we use to connect to our database uses an ini file to map apps to accounts in the database.

Example:


Right now, I'm configuring the account name 'myapp' in the deployment descriptor which means that every time the customer wants to upgrade, they have to unpack the app and edit the web.xml file.

If there was a dependable way to determine the contextPath at startup, it would be possible for them to just rename the war file and drop it in the webapps directory (we're using Tomcat).

I'm very surprised that ServletContext doesn't have a getContextPath method.



This works but it's so replusive that I can't look at it without getting sick.
[ February 28, 2005: Message edited by: Ben Souther ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic