How can I reliably create files from servlets on Linux in a platform-portable way? Code that successfully creates a new file under Windows fails with permission problems under Linux.

Nathan Meyers

The problem is that Linux has a real user and file system security model, and Windows does not. You cannot create files in arbitrary directories - you need to create the file in a directory writable by the process running the servlets. Here are a couple of options:

  • If you are creating a temporary file, use the File.createTempFile() method. This will work on all platforms.
  • If you want to create permanent files, you'll need to write them to a directory to which you know you have write access. You could create a directory with the appropriate ownership and permissions in a known location, or in a location that is advertised through a property set by the servlet environment.
0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact