Can any one post a - code snippet - which can create a .txt file on the application server - using the text from a "textArea" on a JSP page. (Basically the user types some text on the JSP on a client and the text should be saved to a txt-file on ap-server.)
Created May 7, 2012
Jouni Hämäläinen
Hi, this works in my own computer:
<%@page import="java.io.*"%>
<%
String textFromTextArea = request.getParameter("message");
if(textFromTextArea!=null){
String path = "c: empfile.txt";
File file = new File(path);
Writer writer = new BufferedWriter(new FileWriter(file));
writer.write(textFromTextArea);
writer.flush();
writer.close();
}
%>
It gets the value of field "message" and saves it in file.txt.