Solved

java save form to a file

Posted on 2007-11-25
4
1,748 Views
Last Modified: 2008-02-01
hi there
I am learning servlet and trying to save the data entered from a form to a file before it generate the html. Can you please help me how I can do that
Also how will I use the saved file to upload to the form


Thanks
0
Comment
Question by:dminh01
  • 2
4 Comments
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
Just get the field values from the request and append them to a file:

out.println(req.getParameter("a")); //etc
0
 
LVL 17

Accepted Solution

by:
contactkarthi earned 250 total points
Comment Utility
to write to a file see the below link
http://www.exampledepot.com/egs/java.io/WriteToFile.html

to get the values from the form in a servlet
http://www.exampledepot.com/egs/javax.servlet/GetReqParam.html

combine both of them to get what you need
0
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 250 total points
Comment Utility

PrintWriter out = new PrintWriter(new FileWriter("formvals.properties"));

for (Enumeration e = req.getParameterNames(); e.hasMoreElements();) {

	String name = (String)e.nextElement();

	out.println(name + "=" + req.getParameter(name));

}

out.close();

Open in new window

0
 

Author Comment

by:dminh01
Comment Utility
Thanks CEHJ
How about posting from that file back to the form?


thanks
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now