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

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.

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact