I have to make a folder from a servlet in the project's web directory. (Like: web/Users/userinform) To do that i make a call to the helper class that works to make a directory but it is unable to make one. Even if i invoke mkdir
from within the servlet then also directory is not made. (returns false) What is the reason ? How can i do so ?
我必须在项目的web目录中从servlet创建一个文件夹。 (例如:web / Users / userinform)要做到这一点,我调用了一个帮助程序类,它可以创建一个目录但是无法创建一个目录。即使我从servlet中调用mkdir,也不会创建目录。 (返回false)是什么原因?我怎么能这样做?
EDIT
2 个解决方案
#1
0
Try like this
试试这样吧
new File(request.getRealPath("users") + "/me@this.com").mkdir();
Never you should rely to modify in deployed web application.
您永远不应该依赖于在已部署的Web应用程序中进
Refer this modify properties file in Tomcat during runtime
在运行时期间在Tomcat中引用此修改属性文件
#2
0
First, maybe you need to use the "mkdirs()" flavor of the call, ensuring all parents are created also.
首先,也许您需要使用呼叫的“mkdirs()”风格,确保所有父母也被创建。
Second, where do you assume your directory to be created: as a child of the web application deplyoment path? Then answer of @Srikanth should work - recheck.
其次,您在哪里假设要创建的目录:作为Web应用程序deplyoment路径的子级?然后回答@Srikanth应该工作 - 重新检查。
If you try to write outside this path, you should double check the file system permissions (not yours, but the user that is finally running the glassfish).
如果您尝试在此路径之外编写,则应仔细检查文件系统权限(不是您的,而是最终运行glassfish的用户)。
#1
0
Try like this
试试这样吧
new File(request.getRealPath("users") + "/me@this.com").mkdir();
Never you should rely to modify in deployed web application.
您永远不应该依赖于在已部署的Web应用程序中进
Refer this modify properties file in Tomcat during runtime
在运行时期间在Tomcat中引用此修改属性文件
#2
0
First, maybe you need to use the "mkdirs()" flavor of the call, ensuring all parents are created also.
首先,也许您需要使用呼叫的“mkdirs()”风格,确保所有父母也被创建。
Second, where do you assume your directory to be created: as a child of the web application deplyoment path? Then answer of @Srikanth should work - recheck.
其次,您在哪里假设要创建的目录:作为Web应用程序deplyoment路径的子级?然后回答@Srikanth应该工作 - 重新检查。
If you try to write outside this path, you should double check the file system permissions (not yours, but the user that is finally running the glassfish).
如果您尝试在此路径之外编写,则应仔细检查文件系统权限(不是您的,而是最终运行glassfish的用户)。