0

I have a web form page (jsp) ,where user gives some variables. I have a java class which has the same names.So with jsp bean i pass the user's input into 2 variables. So i have var_1=greek,var_2=turkey.

I want now to pass these variables to a properties.txt file with a servlet.The problem is that it gives me this error:

/properties.txt (Permission denied)

to make the servlet i followed this example:WriteToFileServlet

How i can write to a file, my variables??

oikonomopo
  • 4,025
  • 7
  • 44
  • 73
  • 1
    permission denied just means that the servlet is trying to write to a place where it's not authorized to write. Choose a directory that is writable by the OS user under which the servlet container runs. – JB Nizet May 31 '12 at 19:27
  • "/properties.txt" is the path you are writing to. Or is it relative to the application content directory. – Ramesh PVK Jun 01 '12 at 11:19
  • It is relative to the application content directory – oikonomopo Jun 01 '12 at 18:26

2 Answers2

2

You need to change permission to your server directory that it would be writable. Linux command: chmod 777 dirName provides full permissions to that directory.

If you want all folders and files in specific directory to be writable too, you have to run this command: chmod 777 -R dirName.

To get more info about permissions you should read this: http://www.techrepublic.com/article/linux-file-and-directory-permissions/1047531

Paulius Matulionis
  • 23,085
  • 22
  • 103
  • 143
0

You should try writing to the file which is relative to the application content directory.

String path = servletContext.getRealPatch("/tmp/properties.txt");
//write to path 
Ramesh PVK
  • 15,200
  • 2
  • 46
  • 50