nabbler12999 wrote:
Hello,
I want to read a directory. But canRead() gives false. How can I do it?
Firstly, you show this code as a scriptlet; while you certainly can do
this sort of thing from a JSP, such logic really belongs in your action.
That asside:
My code:
[code]
<%
String filename="";
File dir = new File("files");
Since you've specified the directory as a relative path, I'm not sure it
the Servlet spec gives you any guarantee as to where the system will
look for the 'files' directory; relative to the root of the webapp? to
the installation directory of the container? to the directory you were
in when you launched the webapp? ... Try using an absolute path.
[...]
One other point you should note: if your intention is to locate this
directory of files within your webapp, you should use a different
approach to reading them. There is no guarantee that you can do a simple
file read of a web application resource, as the container isn't required
to unpack the WAR file. If this is what you are trying to do, you should
use one of the getResource methods to access the file from the servlet
context or classpath.
L.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]