Problem with appending data to the end of file

Problem with appending data to the end of file

MY JSP CODE WITH THE JAVA CLASS: JSP CODE:

<html>
<body>
<%@ page language="java" import="java.io.*,data.*" %>
<%
String name=request.getParameter("name");
String mail=request.getParameter("email");
%>
<%
ServletContext sc=getServletContext();
String path=sc.getRealPath("mailList.txt");
musicja ja=new musicja();
ja.add(name,mail,path);
out.println("<h1>Ur name has been added successfully</h1>");
%>
</body>
</html>

JAVA CLASS FILE CODE:

package data;

import java.io.*;
import java.util.*;

public class musicja
{
public static void add(String name,String mail,String path) throws IOException
{
File f=new File(path);
PrintWriter p=new PrintWriter(new FileWriter(f,true));
p.println(name+"|"+mail+"|");
p.close();
}
}

My problem is that everytime i enter the data(via the browser),the data that i entere is printed on the text file(mailList.txt),but the data doesn't append,in the sense,everytime the previous data is deleted and the new data is printed in the file.Please do let me know if m missing something in the code or if i need to add something more.

View Answers

Ads









Related Tutorials/Questions & Answers:
Problem with appending data to the end of file
Problem with appending data to the end of file  MY JSP CODE... the data(via the browser),the data that i entere is printed on the text file..." import="java.io.*,data.*" %> <% String name=request.getParameter("name
writing and appending to a file
writing and appending to a file  My input file includes data from... and values and writes into an existing file for 'male'. How can I do the same... the new data fw.write("# Table" + Name + "\n" + "map
Advertisements
how to write to file at the end of the line
how to write to file at the end of the line  Hi, Where do i learn how to write to file at the end of the line using Java program. Plz suggest... will help you for "How to write the file at the end of line using Java language
Is data science a dead end job?
Is data science a dead end job?  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: Is data... that I can learn the topic "Is data science a dead end job?". Also
File Uploading Problem
File Uploading Problem  I have a file uploading code but it create problem $(document).ready(function(){ $('#upload').click(function(){ var...', dataType: 'json', url: 'myServlet', data:{path:fileName}, contentType
File Uploading Problem
File Uploading Problem  I have a file uploading code but it create problem $(document).ready(function(){ $('#upload').click(function(){ var...', dataType: 'json', url: 'myServlet', data:{path:fileName}, contentType
Problem reading word file
Problem reading word file  Deepak you provide me code for extarcting equation from a word file and also to write in a word file.But when I again want to read preveously created word file(created by your code) it gives an error
application context file problem
application context file problem  how to configure junit application context file with struts........? it is not finding sessionfactory method
struts jar file problem
struts jar file problem  hi.. I'm using struts-core-1.3.9.jar. it works well if am using ma application with internet but it shows me an error while initializing ActionServlet when i disconnected to Internet The error stack trace
problem while reading .csv file
problem while reading .csv file  I have a problem here..... i am reading a .csv extention file which has some value....but the problem is der is an amount column which contains , in between (eg) 3,899.00 which inturns creates
reached end of file while parsing and while expected
reached end of file while parsing and while expected  import java.io.*; public class temperature{ public static void main(String []args)throws IOException{ BufferedReader steffi = new BufferedReader (new
bliffoscope data analsys problem
bliffoscope data analsys problem  Bliffoscope Data Analysis Problem... problem you have is detecting the Rejectos spaceships and slime torpedos, because... is. In other words, the data it provides is the equivalent of a black-and-white image
Problem in getting file path in js
Problem in getting file path in js  hi, I am using ofbiz framework , How i can get the file path in javascript for input type = "file" and i am using only firefox not other browser. so please help me it is very important for me
jTable data problem
jTable data problem  Hello. I have a code that read file and store...","Number"}; List<String> data=new ArrayList<String>(); String... that read file and store in arraylist and then convert to array(To use for table
Write a program in Java to append content at the end of an already existing file.
Write a program in Java to append content at the end of an already existing file.  Write a program in Java to append content at the end of an already existing file
Java Write To File End Of Line
Java Write To File End Of Line In this tutorial you will learn how to write to file at the end of the line. Write to a file in which some contents are available already and you need to write the text at the end of line you may to use
Problem in accessing data from Database
Problem in accessing data from Database  hi..... i'm making a project... is text and all others are of currency data type. If i enter 0 or null value in currency column and then try to retrieve data using my servlet coding
a problem during add jar file javax.annotation.Resource
a problem during add jar file javax.annotation.Resource   when i use this jar file in my application i got this problem pls tell me about it Access restriction: The type Resource is not accessible due to restriction on required
generating mock data class of times (start and end time and value)
generating mock data class of times (start and end time and value)   Using the timertask function want to generate a set of mock data of times using the random DATE class and values for plotting on a graph using java. How
How we delete a data of database from front end jsp page
How we delete a data of database from front end jsp page   I make a website and featch a data from data base and now i want that a delete button put in front of a featched data and when i clicked on this button then the data
FTP file copy problem? - Java Beginners
FTP file copy problem?  Hi, Can any one tell me how to set file...-net-1.4.1.jar to copy files from local system to server. Eg: local file name ?test.doc? (Today, December 29, 2009, 5:09:33 PM) when I moving this file to server, the files
Problem in enctype="multipart/form-data" in JSP
Problem in enctype="multipart/form-data" in JSP  im using a page... the file itself when i click the submit button. im using enctype="multipart/form-data... the uploaded value. but the problem is the uploaded file is not stored
problem on jsp, inserting data into table(mysql).
problem on jsp, inserting data into table(mysql).  hello friends, I have a problem in jsp.I want to insert data, which is given by user through... is in mysql.I want to use placeholder("?") to insert data into table.Plsssss help
problem of writing to a local file ( JApplet ) - Applet
problem of writing to a local file ( JApplet )  Dear All, I want to program a guestbook using java applets but now I have problem of writing to a file from JApplet. it is working without any problem if i run the program using
problem with executing JSF file(Build failed)
problem with executing JSF file(Build failed)  *while executing below code i am getting problem as **init: deps-module-jar: deps-ear-jar: deps... Compiling 1 source file to /root/NetBeansProjects/JSFProject3/build/generated/classes
Write data in doc file
Write data in doc file  How to write data or string in word file
Example of appending to a String
Example of appending to a String  Hi, Provide me the example code of appending to a Java program. Thanks   Hi, Check the tutorial: How To Append String In Java? Thanks
Appending String efficiently in Java
Appending String efficiently in Java  Hi, Share me the example code for Appending String efficiently in Java. Thanks   Hi, StringBuilder class of Java API is used by developers of Java for appending string
Insert Data From File
Insert Data From File       Insert Data From File is  used to insert data from file... to insert data from file. To understand this example, we create a table 'Stu_Table
Appending Strings - Java Tutorials
.style1 { text-align: center; } Appending Strings In java, the two main ways for appending string at the end are : First method is using += operator. Second method is using append()  method. In this section, we
File and data sending
File and data sending  Can anyone please tell me how to upload a file along with some data into the server??I want to do it like the way they do...(file_data) values(?)"); fis = new FileInputStream(f); psmnt.setBinaryStream(1

Ads