Actually, this doesn't work either.  getContextPath returns the part of the 
URL that corresponds to the Context.

Assuming that you are using a file-based context, and you can control how 
the app is deployed (i.e. it is always deployed under webapps), then this 
might be one of the few real uses of getRealPath.  Something like:
   String path = getServletContext().getRealPath("/../project/myfile");

Otherwise, you are pretty much stuck with the CATALINA_HOME env variable (or 
the equivalent catalina.home System property).

"Mark Shifman" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Actually you asked for the home directory so you could use
> http://java.sun.com/products/servlet/2.5/docs/servlet-2_5-mr2/javax/servlet/ServletContext.html#getContextPath()
> Mark Shifman wrote:
>> You could try
>> http://java.sun.com/products/servlet/2.5/docs/servlet-2_5-mr2/javax/servlet/ServletContext.html#getResource(java.lang.String)
>> or
>> http://java.sun.com/products/servlet/2.5/docs/servlet-2_5-mr2/javax/servlet/ServletContext.html#getResourceAsStream(java.lang.String)
>> mas
>>
>> Ar5eNiC wrote:
>>> Hello,
>>>
>>> I am currently on a team developing a web interface that allows the user 
>>> to
>>> click drop downs to change content in an html page. We are calling our 
>>> java
>>> methods using a JSP page. One of our java methods needs to access a file
>>> that is in our projects folder under webapps. We cannot use relative 
>>> paths
>>> because they change depending on where tomcat is started from. We also 
>>> would
>>> perfer to not use the CATALINA_HOME environment variable, even though it
>>> would be the best solution. Is there any other way we'd be able to get
>>> tomcat's home directory from a java program?
>>>
>>> Thanks in advance.
>>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
> 




---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to