• Post Reply Bookmark Topic Watch Topic
  • New Topic

Unable to save file in the WEB-INF dir

 
paolo belletti
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all

I'm having a small problem trying to access or anyway store a file in the Tomcat's WEB-INF directory.
I have a class that prints into a file named "users.txt", the printing action described in the "add()" method works properly for other directories e.g:desktop but it wont in the WEB-INF
The User object its a simple object that describes basic users info such as name, last name and email in a String value, here is the UserIO class code (imports are fine)


And this is how i'm trying to access the file, using the getRealPath() method from the ServletContext instance:



its a problem of having the rights for accessing the WEB-INF dir, any advice?
Thank you

 
Tom Reilly
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, WEB-INF is generally write protected. For security reasons, you should not try to change it. If you _must_ write to a file, you should write it to another area. But a better design is to keep that data in a database.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!