A
anikkar
hi,
I am just getting started with JSPs, and i am writing a few small
utility files, and i am having trouble writing to a text file.
my java file is as such:
import java.io.*;
public class Utils {
public static final int EOF = -1;
public static String writeFile(String file) {
try {
BufferedWriter out = new BufferedWriter(new FileWriter(file));
out.write("This is a test");
out.close();
return "succes";
}
catch(Exception e) {
return e.getMessage();
}
}
}
and my jsp:
<%@ page import="java.util.Enumeration"%>
<%@ page import="com.lambandtunafish.Utils"%>
<html>
<body>
<B>Test</B><BR>
<%
out.println(Utils.writeFile("/home/content/b/u/d/budweiser/html/test/test.txt"));
%>
</body>
</html>
But when I run it, I get the following:
access denied (java.io.FilePermission
/home/content/b/u/d/budweiser/html/test/test.txt write)
I have tried it both when the test.txt file exists, and does not exists
(i.e. java creates the file). I do have read permission, as I have been
able to read from the file.
what I am having trouble with is setting the write permission
I have tried contacting my hosting company, and as usual i got the
simple response of: "make sure your permissions are set
correctly"...which i'm not so sure on how to do that with java...any
ideas..thanks!?
I am just getting started with JSPs, and i am writing a few small
utility files, and i am having trouble writing to a text file.
my java file is as such:
import java.io.*;
public class Utils {
public static final int EOF = -1;
public static String writeFile(String file) {
try {
BufferedWriter out = new BufferedWriter(new FileWriter(file));
out.write("This is a test");
out.close();
return "succes";
}
catch(Exception e) {
return e.getMessage();
}
}
}
and my jsp:
<%@ page import="java.util.Enumeration"%>
<%@ page import="com.lambandtunafish.Utils"%>
<html>
<body>
<B>Test</B><BR>
<%
out.println(Utils.writeFile("/home/content/b/u/d/budweiser/html/test/test.txt"));
%>
</body>
</html>
But when I run it, I get the following:
access denied (java.io.FilePermission
/home/content/b/u/d/budweiser/html/test/test.txt write)
I have tried it both when the test.txt file exists, and does not exists
(i.e. java creates the file). I do have read permission, as I have been
able to read from the file.
what I am having trouble with is setting the write permission
I have tried contacting my hosting company, and as usual i got the
simple response of: "make sure your permissions are set
correctly"...which i'm not so sure on how to do that with java...any
ideas..thanks!?