Enter your email address:

Delivered by FeedBurner


Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
create a file from form input in java,jsp
12-19-2011, 06:32 PM (This post was last modified: 12-19-2011 06:33 PM by rajasri.)
Post: #1
Sad create a file from form input in java,jsp
Here we are going to learn how to create the file from form input ie when we submit the form one file is created

Quote:<form name="f" method="get" action="#">
File Name:<input type="text" name="name"/>
Msg:<input type="text" name="msg"/>
<input type="submit" value="submit">
</form>

<%@page import="java.io.*"%>
<%
String name = request.getParameter("name");
if(name==""||name==null)
{
name="Filename:example";
}
else
{
out.println("<script type='text/javascript'>alert('File created in c: with your given file name');</script>");
}
String msg = request.getParameter("msg");
if(msg==""||msg==null)
{
msg="Created in c:/example.txt";

}

String path = "c:\\"+name+".txt";
File f = new File(path);
Writer objWriter = new BufferedWriter(new FileWriter(f));
objWriter.write(name+"\n");
objWriter.write(msg+"\n");
objWriter.write("===============================\n");
objWriter.flush();
objWriter.close();

%>
Filename:Type as example
Created in c:/


Here the path is assigned to get the file in text format you can use your own format like html etc. String path = "c:\\"+name+".txt"; and objWriter.write(name+"\n"); is used to write the datas in to the file
Any Doubt ask us.

Happy Coding.
Find all posts by this user
Add Thank You Quote this message in a reply
Advertise here or at any positions around our site send a mail to info@walkinsforum.com
Post Reply 


[-]
Share/Bookmark (Show All)
Facebook Linkedin Technorati Twitter Digg MySpace Delicious

Possibly Related Threads...
Thread: Author Replies Views: Last Post
Tongue Students management java project download rajasri 25 2,290 05-15-2012 12:45 PM
Last Post: itischinmay
  shopping cart in jsp&java admin 6 1,072 04-13-2012 08:51 PM
Last Post: sushantkop
Sad how to import a csv file values in to database using jsp rajasri 2 1,211 02-20-2012 12:17 PM
Last Post: rajesh2407
Photo Convert jar to exe file rajasri 3 1,241 02-12-2012 04:55 PM
Last Post: ionutcib
Sad java.sql.SQLException: General error solution rajasri 3 1,089 02-07-2012 03:05 PM
Last Post: shahbaz07dbit
Information create a war file using jsp code rajasri 0 194 12-19-2011 06:18 PM
Last Post: rajasri
Wink Reading Html code of all the url using java rajasri 0 186 12-19-2011 06:17 PM
Last Post: rajasri
Sad how to delete a file using jsp rajasri 0 265 12-19-2011 06:02 PM
Last Post: rajasri
Star pagination in jsp,java rajasri 0 237 12-19-2011 05:32 PM
Last Post: rajasri
Music How to extract war file in java rajasri 0 2,887 12-14-2011 12:07 PM
Last Post: rajasri

Forum Jump:


User(s) browsing this thread: 1 Guest(s)