-
February 20th, 2002, 09:50 AM
#1
Tabulate a survey using a servlet & writing to a file
Hi!!
I need to develop a questionnaire and tabulate users' answers.
I will use a servlet to process the questionnaire and write the answers to a file.
Could someone give me info on how do I write to a file using servlets??
Any new idea on how to develop my questionnaire is accepted!!
Thanks a lot.
JNP
-
February 20th, 2002, 09:52 AM
#2
Re: Tabulate a survey using a servlet & writing to a file
I think you can use the same classes to write to a file from a servlet as from any other java application.
Norm
Norm
-
February 21st, 2002, 03:00 PM
#3
Re: Tabulate a survey using a servlet & writing to a file
I am having some problems appending to a file. I used
FileWriter fout = new FileWriter(outputFile,true);
to make the append.
my code doesnt compiles.
this is the code for the file tasks
String outputFileName = "c:/text.txt";
File outputFile = new File(outputFileName);
FileWriter fout = new FileWriter(outputFile,true);
FileWriter fout = new FileWriter(outputFile,true);
fout.write("This will be the appended data");
The error is the following:
cuestionario.java [57:1] cannot resolve symbol
symbol : constructor FileWriter (java.io.File,boolean)
location: class java.io.FileWriter
FileWriter fout = new FileWriter(outputFile,true);
^
1 error
Errors compiling cuestionario.
Can you tell me what's wrong??
Thanks
JNP
-
February 21st, 2002, 05:19 PM
#4
Re: Tabulate a survey using a servlet & writing to a file
Hi,
I think it's pretty obvious what's wrong:
the FileWriter class doesn't have a constructor which takes a File and boolean as arguments. You should pass the instead the file name and the boolean; the following code should compile
FileWriter out = new FileWriter(outputFileName, true);
regards,
Claudiu
Brainbench MVP for C++
ICQ #: 65097130
Make sure you rate the post if helped ! This encourage people to respond.
-
February 21st, 2002, 05:25 PM
#5
Re: Tabulate a survey using a servlet & writing to a file
I solved the problem about appending to a file. Now I have all the user's answers on a file named respuestas.txt. I am completely stock here. I dont know how to tabulate the results. What I need is to determine how many persons answered a, how many answered b (as an example)... etc Please give me some ideas.
JNP
-
February 21st, 2002, 06:03 PM
#6
Re: Tabulate a survey using a servlet & writing to a file
You'll have to do some problem analysis here.
There are many solutions depending on what the data looks like and how you are able to read thru it.
For example, have a loop that iterates thru all the persons and have a group of counters for the answers;
In pseudo code:
start loop:
get next person
if person answered ques_a
ques_a_cnt++; // count
if person answered ques_b
ques_b_cnt++;
... etc
end loop;
Norm
Norm
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|