is there a policy type file needed for JSP file privileges?

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!?
 
J

josh.s17

It may be related to the way your application server is configured. I
know with websphere the default settings do not allow an application to
write to the file system.
 
A

anikkar

yea, that may be the case, if so, does that mean I am pretty much
screwed if I want to do any File output?

my provider is godaddy, and theier tomcat version is 5.0.27.
 
J

josh.s17

I'm not familiar with changing that setting for Tomcat but I'm sure it
is possible. Whether your provider will allow you to change it is
another matter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top