|
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
|
|||
|
|||
Quote:<form name="f" method="get" action="#"> <%@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.
|
|||
Advertise here or at any positions around our site send a mail to info@walkinsforum.com
|
« Next Oldest | Next Newest »
|
![]() |
|||||||
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
|
| Possibly Related Threads... | |||||
| Thread: | Author | Replies | Views: | Last Post | |
| 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 |
|
| 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 |
|
| Convert jar to exe file | rajasri | 3 | 1,241 |
02-12-2012 04:55 PM Last Post: ionutcib |
|
| java.sql.SQLException: General error solution | rajasri | 3 | 1,089 |
02-07-2012 03:05 PM Last Post: shahbaz07dbit |
|
| create a war file using jsp code | rajasri | 0 | 194 |
12-19-2011 06:18 PM Last Post: rajasri |
|
| Reading Html code of all the url using java | rajasri | 0 | 186 |
12-19-2011 06:17 PM Last Post: rajasri |
|
| how to delete a file using jsp | rajasri | 0 | 265 |
12-19-2011 06:02 PM Last Post: rajasri |
|
| pagination in jsp,java | rajasri | 0 | 237 |
12-19-2011 05:32 PM Last Post: rajasri |
|
| How to extract war file in java | rajasri | 0 | 2,887 |
12-14-2011 12:07 PM Last Post: rajasri |
|
User(s) browsing this thread: 1 Guest(s)






![[-]](images/royal_red/collapse.gif)






