You can use the method getRealPath() of the javax.servlet.ServletContext. In
case of JSP page you can use:
String absPath = config.getServletContext().getRealPath("/");
> -----Original Message-----
> From: Felix Munoz [mailto:[EMAIL PROTECTED]]
> Sent: Montag, 7. Mai 2001 10:26
> To: '[EMAIL PROTECTED]'
> Subject: [JBoss-user] (no subject)
>
>
> Hello:
>
> I am having a problem running a JSP and I was hoping for some
> advice. I am
> running embedded Tomcat.
>
> I have the following setup:
>
> index.jsp
> directory/fileA.txt
> directory/fileB.txt
>
> The job of index.jsp is to list the files in "directory." For
> this, I was
> trying to use something like this:
>
> File directory = new File("directory")
> String[] fileList = directory.list();
>
> Of course, because JSP needs to be compiled, and it is done
> so in another
> directory, when this code is run index.jsp does not find the
> "directory"
> directory.
>
> If I change the file path to an absolute path
>
> File directory = new
> File("C:/JBoss/temp/deploy/MyWAR.war/web1005/directory");
>
> it works fine. I am using this path because it is the only
> one I can find in
> the JBoss directory and in the Tomcat directory. Of course,
> this is not a
> standard path and, to make things worse, every time I deploy
> the WAR file
> the "web1005" token changes to something else.
>
> So the question is, is there a way to list files in a
> directory by using a
> path relative to the location of a JSP page?
>
> Thanks in advance,
>
> Felix Munoz
>
> _______________________________________________
> JBoss-user mailing list
> [EMAIL PROTECTED]
> http://lists.sourceforge.net/lists/listinfo/jboss-user
>
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user