Solved

java save form to a file

Posted on 2007-11-25
4
1,766 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 20347118
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
ID: 20347132
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
ID: 20347165

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
ID: 20347515
Thanks CEHJ
How about posting from that file back to the form?


thanks
0

Featured Post

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

623 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