I would like to capture a single parameter from a httpRequest or maybe an AJAX request. I would like to write that parameter to a text file. I am using Netbeans 6.5 with the Apache Tomcat 5. This is the platform that the project will be shown on, so it's OK that it isn't "live". Currently the text file is in the "web" folder of my project folder. I have two pieces of code which I was planning on using to write the text to a file, but I'm unsure if either will work, or which is better.
or this one
I am also concerned that the file will be overwritten instead of appended. Should I create a new line using /nl inside its own oute.write or println statement?
P.S. I modified the subject line to curtail any urges to move this post to the Servlets forum. If you have any further questions on file addressing in servlets, please open a new topic in Servlets, and we can leave this one here for the I/O parts.
Joined: May 26, 2009
The only reason I mentioned servlets is because I wasn't sure I could use generic Java I/O in a servlet. I thought there might be something servlet specific that I would have to do. It looks like either of these would work then. I'll work on it some more. If any of the file I/O guys have any comments or cautions, I'd appreciate it.