Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 我不能在文件中写字_Java_Jsp_Cpanel - Fatal编程技术网

Java 我不能在文件中写字

Java 我不能在文件中写字,java,jsp,cpanel,Java,Jsp,Cpanel,我使用tomcat5.32+cpanel 我的代码是: <% String path = application.getRealPath(""); path +="/as.txt" ; FileOutputStream fos = new FileOutputStream(path); fos.write("this is test ?".getBytes()); fos.flush(); fos.close(); %> 请求时,获取此错误: java.io.FileNotFo

我使用tomcat5.32+cpanel

我的代码是:

<%
String path = application.getRealPath("");
path +="/as.txt" ;
FileOutputStream fos = new FileOutputStream(path);
fos.write("this is test ?".getBytes());
fos.flush();
fos.close();
%>

请求时,获取此错误:

java.io.FileNotFoundException: /home/domainname/public_html/ROOT/as.txt (Permission denied)
java.io.FileOutputStream.open(Native Method)
java.io.FileOutputStream.<init>(FileOutputStream.java:179)
java.io.FileOutputStream.<init>(FileOutputStream.java:70)
org.apache.jsp.newjsp2_jsp._jspService(newjsp2_jsp.java:61)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:259)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
java.io.FileNotFoundException:/home/domainname/public\u html/ROOT/as.txt(权限被拒绝)
java.io.FileOutputStream.open(本机方法)
java.io.FileOutputStream。(FileOutputStream.java:179)
FileOutputStream.java.io.FileOutputStream。(FileOutputStream.java:70)
org.apache.jsp.newjsp2_jsp._jsp服务(newjsp2_jsp.java:61)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javaservlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:259)
javaservlet.http.HttpServlet.service(HttpServlet.java:729)
perms是0644,但我的程序不能在自己的文件中写入


请帮助我

错误很明显,您没有对该文件的写入权限

您的权限,
0644
仅向拥有该文件的用户添加
Read/Write
权限。任何一个 使您的Tomcat用户成为所有者,或者将该用户包括到文件组中,并应用权限
0664

1)确保尝试写入此文件的“用户”实际拥有权限。JVM写入磁盘的权限可能与启动JVM的用户不同


2) 在尝试写入文件之前,请确保该目录路径的所有步骤都已存在。

根目录的所有者是否与运行tomcat服务器的用户相同?我应用权限0664。但是get permission错误。@amir2,你确定Tomcat用户也是文件所属组的成员吗?my host管理员说:Tomcat用户是Nobody组的成员。root@panther[~]#组tomcat tomcat:没人,什么是没人组?@Amir2,只是一个名称-组基本上可以被命名为任何东西。文件是否也属于组
Nobody
?我的主机经理说:public\u html是Nobody的成员。请帮帮我!