Forum Stats

  • 3,815,606 Users
  • 2,259,059 Discussions
  • 7,893,185 Comments

Discussions

I can not write in file

892095
892095 Member Posts: 1
hi
i use tomcat5.32 + cpanel .

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

when requested get this error :

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)

the perms is 0644 or 0664 but my program can not write in own files .

please help me !!
Tagged:

Answers

  • 892936
    892936 Member Posts: 5
    Are you sure that the tomcat process is run by the right user that actually has permission to write the file?
    The file's permissions might be '664' to you, but maybe the tomcat process's user is not in the correct group.
This discussion has been closed.