File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Writing to a text file

 
Brooke Maddox
Ranch Hand
Posts: 42
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure if this is the correct forum, and I am very new to JSF so please bear with me.
I have a JSP page where a user can enter information which will then be written to a text file.
I have a class that has a method to write to the text file.
My problem ( I think ) is that I am not getting the right location of the text file and the path to it.
Here is the code of my class
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17621
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are attempting to write data into your WAR, using a relative path.

1. You should not attempt to use a relative path in J2EE apps. The current directory that the path is relative to is unpredictable and can be changed without notice.

2. You should NEVER attempt to write anything into a WAR or into any of the directories that your webserver live in. The WAR should be treated as read-only (sometimes it is), and even if you can write to it, any data written there may not stay written there.

It is better to select a directory that is external to your webserver and write your files into it.
 
Brooke Maddox
Ranch Hand
Posts: 42
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Tim :)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic