由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - servlet读取directory的基本问题
相关主题
使用JAVA的一则经验和教训How do I send cookies from a servlet?
Any free LDAP server?理解Java Servlets [fwd]
[转载] Urgent Help needed about Java Servlet?Another Servlet Problem:Browser Caching
问一个J2EE和Tomcat问题need your comments
请教高手如何用JUnit模拟真实的Servlet容器 (e.g. Jboss里的tomcat), 具体需求请进JSP tag file and EL warnings
Run Servlet with Tomcat请推荐servlet还有jsp的书
急问:装了JSDK2.0,servlet engine 不 运 行 ?运行servlet时出现的http status 404问题
sevlet question愣是笨到家----整不明白applet的path
相关话题的讨论汇总
话题: subfolder1话题: file话题: directory话题: servlet话题: app
进入Java版参与讨论
1 (共1页)
f*n
发帖数: 254
1
jboss做server,最基本的servlet,想列出诸如/subfolder1下所有文件
用File f1 = new File("/subfolder1"),但f1.isDirectory()returns false。。。
从而没法再运行list()。
请问应该怎么做?谢谢。。。
t*******e
发帖数: 684
2
这个和Servlet没什么关系。搞清Java IO的基本操作就可以了。确保path is valid.
f*n
发帖数: 254
3
谢谢,path没有问题,但是有没有什么security设定啊,现在在浏览器里输入
/subfolder1/file.txt可以显示下载,但是输入/subfolder1则显示找不到。。。

【在 t*******e 的大作中提到】
: 这个和Servlet没什么关系。搞清Java IO的基本操作就可以了。确保path is valid.
t*******e
发帖数: 684
4
You are confused between the directory listing feature of web servers, and
Java IO streaming.
f*n
发帖数: 254
5
thanks... I guess so but cannot find any examples. I followed this but
failed:
http://www.javajunkies.org/index.pl?node_id=3568&lastnode_id=41

【在 t*******e 的大作中提到】
: You are confused between the directory listing feature of web servers, and
: Java IO streaming.

c********g
发帖数: 449
6
I think full path should be used in java servlets.
my codes for your reference:
static final String USER_DIR = "C:\\users\\";
static final String WORK_DIR = "C:\\work\\";
they have been really working on tomcat on Windows.
c********g
发帖数: 449
7
also try File f1 = new File("/subfolder1/");
"/subfolder1" -->"./subfolder1/"
g*****g
发帖数: 34805
8
I think you are confused with relative path. For path
used in web app, normally you have 2 choices.
1. Pass in a root web app directory as a property to the app
2. Use classpath resource and keep your files in $App/classes
That way, you achieve portability.

【在 f*n 的大作中提到】
: 谢谢,path没有问题,但是有没有什么security设定啊,现在在浏览器里输入
: /subfolder1/file.txt可以显示下载,但是输入/subfolder1则显示找不到。。。

f*n
发帖数: 254
9
明白一点了。也就是说,choice 1需要给出app在server的local directory path是吧。
谢谢。。。

【在 g*****g 的大作中提到】
: I think you are confused with relative path. For path
: used in web app, normally you have 2 choices.
: 1. Pass in a root web app directory as a property to the app
: 2. Use classpath resource and keep your files in $App/classes
: That way, you achieve portability.

g*****g
发帖数: 34805
10
You can put a properties file in classes folder and
configure it whatever way you want.
Typically web application will load some properties file
to do config in startup.

吧。

【在 f*n 的大作中提到】
: 明白一点了。也就是说,choice 1需要给出app在server的local directory path是吧。
: 谢谢。。。

f*n
发帖数: 254
11
试了一下明白了。谢谢。

【在 g*****g 的大作中提到】
: You can put a properties file in classes folder and
: configure it whatever way you want.
: Typically web application will load some properties file
: to do config in startup.
:
: 吧。

1 (共1页)
进入Java版参与讨论
相关主题
愣是笨到家----整不明白applet的path请教高手如何用JUnit模拟真实的Servlet容器 (e.g. Jboss里的tomcat), 具体需求请进
请问javax.portlet包在JDK的哪个jar文件里面(在线等)Run Servlet with Tomcat
JAVA 一族急问:装了JSDK2.0,servlet engine 不 运 行 ?
Re: serverletsevlet question
使用JAVA的一则经验和教训How do I send cookies from a servlet?
Any free LDAP server?理解Java Servlets [fwd]
[转载] Urgent Help needed about Java Servlet?Another Servlet Problem:Browser Caching
问一个J2EE和Tomcat问题need your comments
相关话题的讨论汇总
话题: subfolder1话题: file话题: directory话题: servlet话题: app