Look at the method getRealPath() of class ServletContext. Erwin
Am Dienstag, 23. April 2002 13:41 schrieben Sie: > Hi, > > with getServletContext() I get only the name of my running > web-application; with getServerInfo() I get "Apache Tomcat/4.0.3". > > But I don't get any directory name... > > Frank > > > -----Urspr�ngliche Nachricht----- > > Von: Scott Purcell [mailto:[EMAIL PROTECTED]] > > Gesendet am: Montag, 22. April 2002 18:32 > > An: Tomcat Users List > > Betreff: RE: How can I get the location of the webapps-directory? > > > > 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:[EMAIL PROTECTED]] > > Sent: Monday, April 22, 2002 9:15 AM > > To: [EMAIL PROTECTED] > > 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:[EMAIL PROTECTED]] > > > Gesendet am: Montag, 22. April 2002 06:42 > > > An: [EMAIL PROTECTED] > > > 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:[EMAIL PROTECTED]> > > > > > For additional commands: > > > > <mailto:[EMAIL PROTECTED]> > > > > > Troubles with the list: > > > > <mailto:[EMAIL PROTECTED]> > > > > > -- > > > To unsubscribe: > > > > <mailto:[EMAIL PROTECTED]> > > > > > For additional commands: > > > > <mailto:[EMAIL PROTECTED]> > > > > > Troubles with the list: > > > > <mailto:[EMAIL PROTECTED]> > > > > > > -- > > To unsubscribe: <mailto:[EMAIL PROTECTED]> > > For additional commands: <mailto:[EMAIL PROTECTED]> > > Troubles with the list: <mailto:[EMAIL PROTECTED]> > > > > > > -- > > To unsubscribe: <mailto:[EMAIL PROTECTED]> > > For additional commands: <mailto:[EMAIL PROTECTED]> > > Troubles with the list: <mailto:[EMAIL PROTECTED]> -- To unsubscribe: <mailto:[EMAIL PROTECTED]> For additional commands: <mailto:[EMAIL PROTECTED]> Troubles with the list: <mailto:[EMAIL PROTECTED]>
