tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scott Purcell" <spurc...@vertisinc.com>
Subject RE: How can I get the location of the webapps-directory?
Date Mon, 22 Apr 2002 16:31:57 GMT
I think it is servletContext now. Check out the j2ee for servletContext that may be what you
are looking for.
my o'reilly book shows

public String ServletContext.getServerInfo()


if that don't fly, I can dig deeper, just yell

Scott




-----Original Message-----
From: Eichfelder, Frank [mailto:Frank.Eichfelder@t-systems.com]
Sent: Monday, April 22, 2002 9:15 AM
To: tomcat-user@jakarta.apache.org
Subject: AW: How can I get the location of the webapps-directory?


Hi,

thanks for the reply, but I need the webapps-directory to read the 
existent subdirectories and/or war-files in order to make a list of all
deployed web-applications.

(In older versions of the Servlet-API, there was a method called
getServletNames(), which is deprecated now and returns null)

Does anybody have another suggestion?

Thanks,

Frank

> -----Urspr√ľngliche Nachricht-----
> Von: Rajesh Nair [mailto:rajesh.nair@patni.com]
> Gesendet am: Montag, 22. April 2002 06:42
> An: tomcat-user@jakarta.apache.org
> Betreff: Re: How can I get the location of the webapps-directory?
> 
> Hi 
> I think u can try getContextPath() which will give u the root 
> of ur web application .To get access to resources inside WAR 
> or other archive files u can use the method 
> getResource(String URIPath);
>  If the context is in a different m/c u can use getContext() 
> to get the context first and then use either getResource() or 
> getResourceAsStream() methods 
> 
> *********** REPLY SEPARATOR  ***********
> 
> On 4/19/02 at 3:22 PM Eichfelder, Frank wrote:
> 
> Hi,
> 
> how can I get the location from the webapps-directory on my 
> filesystem?
> 
> It's easy, if I use
> 
> String path = getServletContext().getRealPath("/");
> 
> and then cut off the last part:
> 
> int index = path.lastIndexOf(System.getProperty("file.separator"),
> path.length()-2 );
> 
> path = path.substring(0, index);
> 
> But this works only, if you have your webapplication unpacked in the
> file-system or if you have set unpackWars=true.
> 
> Now, I have set unpackWars=false, and now I get null for
> getServletContext().getRealPath("/").
> 
> Is there any possibility to get the name of the war-File an 
> application is
> stored in or the name of the directory the war-file is stored in?
> 
> Thanks, 
> 
> Frank
> 
> --
> To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
> For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
> Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>
> 
> 
> 
> 
> --
> To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
> For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
> Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>
> 

--
To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>


--
To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>


Mime
View raw message