String fullPath = getServletContext().getRealPath("path");
where path is a context-relative path (can include a filename if you want).
For instance, I use this in a Struts plug-in to initialize a custom connection pool. The value I use for path is "/WEB-INF/ConnPoolConfig.xml". The above gives you the full system path to the file (in my case, C:\tomcat\webapps\toa\WEB-INF on my development machine), so you can easily open it then.
If you just use the above to get the path to a path (i.e., you want the fully-qualified path to WEB-INF in the current webapp, but not a specific file), you will need to append a file separator character at the end before appending a filename.
Frank
From: "Tom K" <[EMAIL PROTECTED]> Reply-To: "Tomcat Users List" <[EMAIL PROTECTED]> To: "'Tomcat Users List'" <[EMAIL PROTECTED]> Subject: RE: How can I access a file located in WEB-INF Date: Wed, 16 Jun 2004 13:52:42 -0500
File dir = new File("directoryName");
String[] children = dir.list(); if (children == null) { // Either dir does not exist or is not a directory } else { for (int i=0; i<children.length; i++) { // Get filename of file or directory String filename = children[i]; } }
Tom Kochanowicz
-----Original Message----- From: STOCKHOLM, Raymond [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 16, 2004 2:15 AM To: Tomcat Users List Subject: How can I access a file located in WEB-INF
Hi,
I need to access a file located in the directory WEB-INF of my web application. In fact, in WEB-INF/conf. How can I open this file in one of my servlet ?
Any advise is welcome.
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.682 / Virus Database: 444 - Release Date: 5/11/2004
--- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.682 / Virus Database: 444 - Release Date: 5/11/2004
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
_________________________________________________________________
MSN 9 Dial-up Internet Access fights spam and pop-ups – now 3 months FREE! http://join.msn.click-url.com/go/onm00200361ave/direct/01/
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]