Writing Form Data to Text Files
This sample of JSP file, first handles all posted data from a web form and write to a text file. We have used Tomcat Server to run our sample code. You could easily edit the source code to use in your application.
The Form Page :
form.html
<html><head>
<title>JSP Examples : Writing Form Data to Text Files</title>
</head>
<body>
<form action="write.jsp" method="post">
Name : <input type="text" name="name">
Message : <textarea name="msg"></textarea>
<input type="submit" name="func" value="Write">
</form>
</body>
</html>
The JSP Page :
write.jsp
<%@page import="java.io.*"%>
<%
String strName = request.getParameter("name");
String msg = request.getParameter("msg");
String func = request.getParameter("func");
if(func!=null){
String strPath = "e:\\\\tomcat\\\\webapps\\\\dotnetindex\\\\example.txt";
File strFile = new File(path);
Writer objWriter = new BufferedWriter(new FileWriter(strFile));
objWriter.write(strName "\\\\n");
objWriter.write(msg "\\\\n");
objWriter.write("===============================\\\\n");
objWriter.flush();
objWriter.close();
}
%>
Happy Coding!
- ASP Chat Box
- Working with Array Remove An Item
- ASPNET Web Counter Free Open Source Code
- Beginning-Ajax-and-ASPNET-35
- How to upload images to mySQL within PHP
- Delete Files Online in ASP
- Video Interview With Roman Strobl
- Custom Paging in ASP Fast And Easy
- How to write and use a JavaBean My frst java bean
- Displaying Records From An Excel Database
- Converting sceonds to hours minutes and seconds
- Paging Results in PHP
- Installing Sun Java System Application Server 9.1 in Solaris Zones
- Java SE 6 Performance White Paper
- Encoding URL strings
- Easy Download Manager Free Version
- ASP Chat Box
- Writing Form Data to Text Files
- Paging Records in JSP
- What is Ecommerce and the Importance of Ecommerce
- Beginning-Ajax-and-ASPNET-35
- How to upload images to mySQL within PHP
- Simple XML RSS Parser
- Counting records in PHP mySQL
- ActiveNews Manager Freeware News Exchange Software
- How to write and use a JavaBean My frst java bean
- Paging Results in PHP
- Free User Registration Form
- A-timesaver-control-GridView
- ASPNET Web Counter Free Open Source Code
- Easy Download Manager Free Version
- ASP Chat Box
- Writing Form Data to Text Files
- Paging Records in JSP
- Beginning-Ajax-and-ASPNET-35
- How to upload images to mySQL within PHP
- Simple XML RSS Parser
- ActiveNews Manager Freeware News Exchange Software
- Counting records in PHP mySQL
- How to write and use a JavaBean My frst java bean
- Paging Results in PHP
- Free User Registration Form
- A-timesaver-control-GridView
- ASPNET Web Counter Free Open Source Code
- Comparing Dates