Write Data to a Flat File from an HTML Form with JSP

How do you write data to a flat file with jsp.I need an example ofa jsp page that can gather information from a html form and insert that data to a flat file.ThanksVic
[195 byte] By [vvicin01] at [2007-9-27 19:13:37]
# 1

Well, this is easy, just construct your text (html) in a String object then open a FileOutputStream and wirte out yur String, here is an example:

FileOutputStream fos=new FileOutputStream(new File(absolutPathToNewFile));

fos.write( stringToWrite.getBytes("UTF-8") );

fos.close();

before in stringToWrite you put the text that you made with te request parameters...

i hope it helps...

condorator at 2007-7-6 21:42:03 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Thank you for the code. How can I write to the file and append the data and not over write the existing string. Currently, each time it writes it over writes the content. I wish to do a new insert with a new line. Thank you - you have been a big help.
vvicin01 at 2007-7-6 21:42:03 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
I'm not trying to sound like a jerk, but read the API dude. There's another constructor you can use that will let you specific whether you want to append or overwrite.
Brian-74-454 at 2007-7-6 21:42:03 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...