aspose file tools*
The moose likes JSF and the fly likes Writing to a text file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Writing to a text file" Watch "Writing to a text file" New topic
Author

Writing to a text file

Brooke Maddox
Ranch Hand

Joined: Nov 23, 2012
Posts: 42
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

Joined: Jun 25, 2001
Posts: 15641
    
  15

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
Brooke Maddox
Ranch Hand

Joined: Nov 23, 2012
Posts: 42
Thank you Tim :)
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Writing to a text file
 
Similar Threads
Beginner needs help with objects
How can i check if the input is the same as the hashmap key.
How do I copy and paste to a text file?
Exception in thread "main" java.lang.NoSuchMethodError: main
Servlet Parameters null