----- Original Message -----
From: "Felix Munoz" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, May 07, 2001 4:25 am
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();
>


Did you try any of these scriptlets (using your example)?

<% File directory = new File(application.getRealPath("directory")) %>
<% File directory = new
File(application.getResource("directory").toExternalForm()) %>
<% application.getResourceAsStream("directory") %>

According to the documentation getResourceAsStream() will read resources
from a war file if it wasn't extracted during deployment. Some application
servers don't extract ears, wars, & jars during deployment unless you
instruct it to do so. This probably doesn't apply to your situation because
you're serving files from a directory.

> 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?


I was going to suggest using something like the IO taglib from
Apache-Jakarta http://jakarta.apache.org/taglibs/index.html. Unfortunately
the IO taglib link on this page is broken. I don't know if it contains a tag
specifically for this purpose but it seems like the best candidate. Perhaps
you should write a tag library to list files. I suspect taglibs already
exist that do this. I just didn't know of any other taglib lists off-hand.

> Thanks in advance,
>
> Felix Munoz

I hope this is helpful.

Regards,

Steve Swing


_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to