Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to get Context-path docbase in a java servlet

Status
Not open for further replies.

Fabmoda

Programmer
Jun 13, 2002
14
IT
hi,
I need to set the System Property "user.dir" equal to the Context-path docbase directory of my servlet. Sombody knows how can I get the Context-path docbase in a java class?
I think that it's possible by using SevletConfig interface in the init method of the servlet but I don't know where that path is.


tnx

fabiano
 
Within the init() method of your main servlet :

System.setProperty(getServletConfig().getServletContext().getRealPath("/"));

--------------------------------------------------
Free Database Connection Pooling Software
 
oops...

System.setProperty("user.dir", getServletConfig().getServletContext().getRealPath("/"));

--------------------------------------------------
Free Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top