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]

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...
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.