Why would one use normal File IO to attempt an absolute file path to the WEB-INF directory of a webapp? Use what the servlet spec provides for you.
String absolutePath = getServletContext().getRealPath("/WEB-INF");
File file = new File(absolutePath);
Just make sure to check for the absolutePath string being null because it will be in the case where you serve the app directly out of a .war file, which is why you shouldn't use File IO unless you absolutely have to. There are plenty of other ways to read files in a servlet app or a generic Java app which doesn't require File IO. Also, if you say "well, I need this so I can write files within my webapp directory", they I would have to say that you've already made your app highly non-portable.
Jake
At 10:22 AM 1/20/2003 +0100, you wrote:
Peter, this may help you,try{ java.io.File dir1 = new java.io.File ("..\\"); // line 1 System.out.println ("Current dir : " + dir1.getCanonicalPath()); String[] contents = dir1.list(); if(contents != null) for(int i=0;i<contents.length;i++) System.out.println ("\n"+contents[i]); } catch(Exception e) { e.printStackTrace(); } First try to go to root directory( by adding more ..\\) , from there loop through the sub directories, find matching file name. Query for the canonical path for that file, you will get the exact path. I supplied you part of code, Hope this helps Madhava Reddy -----Original Message----- From: Christopher Mark Balz [mailto:[EMAIL PROTECTED]] Sent: Monday, January 20, 2003 9:54 AM To: Tomcat Users List Subject: Re: How do I get the absolute path of a file in a directory above WEB-INF directory of my web application? I don't know offhand how you can do that, but if you want to reach up above the WEB-INF directory, you can use dot-dot (..). - CB Peter Lee wrote: >I am using Tomcat for servlets. >How do I get the absolute path of a file in a directory above WEB-INF >directory of my >web application? > >Thanks > > >-- >To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> >For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > > > -- ". . . / This Cabinet is formd of Gold / And Pearl & Crystal shining bright And within it opens into a World / . . . Another England there I saw / Another London with its Tower Another Thames & other Hills / And another pleasant Surrey Bower . . ." - from "The Crystal Cabinet", a poem by William Blake. -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>