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









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
Java check end of file
Java check end of file In this section, you will learn how to check that the file has been read till the end of file. Data has been read one by one from... data. This  indicates the end of file or eof condition. It depends
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
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
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... in the existing file will be written after the end of line i.e. new text
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
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
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
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
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
Problem in inserting clob data in jsp
Problem in inserting clob data in jsp  how to insert any rich text editor data (which have more than 32766 characters) in a clob type column of oracle database with jsp
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
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
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
Java error reached end of file while parsing
Java error reached end of file while parsing       Java Error reached end... an error i.e java error reached end of file while parsing as the class closing braces
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
Write data in doc file
Write data in doc file  How to write data or string in word file
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
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
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
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
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
Insert Data From File
Insert Data From File       Insert Data From File is  used to insert data from file... an example to insert data from file. To understand this example, we create
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
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
extract data fom table when a button is clicked in front end page using mysql5.0 and tomcat6.0
extract data fom table when a button is clicked in front end page using mysql5.0 and tomcat6.0   sir, i want to extract data from table which is stored in mysql5.0 databse, when a button is clicked in front end page using
a little problem in read data - Java Beginners
a little problem in read data  ok Vinod Kumar and friend, i already use this code. but is data null, this code will error5 again. How the data can go to database with null data. ex: value = (d00001;Operation;Finance;Finance Head
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
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
Browse Excel File Problem - Development process
displayed when i browse the file. What is the problem?  Hi Friend...Browse Excel File Problem  I am using a web application,in which i have to browse an excel file columns. It is working in my system. But if i access
How to get the data from the database (Oracle) in console or in ie using servlet or jsp as Front end
How to get the data from the database (Oracle) in console or in ie using servlet or jsp as Front end  hello i have a simple problem in jsp in the sense to get data from the database like oracle . I have created one jsp
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
Insert Data From File
Insert Data From File       Insert Data From File is  used to insert data from file... an example to insert data from file. To understand this example, we create
here we r getting the problem with ut data and get data????????????
here we r getting the problem with ut data and get data????????????  private ArrayList keys; private ArrayList values; public Menus() { keys = new ArrayList(); values = new ArrayList(); } public
Data extraction from an image file.
Data extraction from an image file.  I have made an image... data from the the image which also include deleted data.Can i used java to extract these data from the image file? Which are the libraries to be used
how to store data in XML file - JSP-Servlet
how to store data in XML file  hi i have to store the data for example user id and password in a xml file the input userid and password..., To solve the problem visit to : http://www.roseindia.net/servlets/login-Xml
CONVERT JTable DATA TO PDF FILE
CONVERT JTable DATA TO PDF FILE  HOW TO CONVERT JTable DATA TO .PDF FILE??PLEASE GIVE ME CODE FOR THAT.   Here is an example that reads the jtable data from the jframe and stored the data into the pdf file in the form
problem in creating create .ipa file in my iPhone app
problem in creating create .ipa file in my iPhone app  Hi, does anyone have idea on how to create a .create .ipa file for my iPhone / iPad application? Also do i need to delete the previous build to create .ipa file? Thanks
Inserting data in Excel File - Java Beginners
Inserting data in Excel File  Dear Sir, How can we fill the excel with fetched data from the database like Oracle, DB2? Is it possible to create an excel with filled data? Kindly give me the solutions to questions
Problem to print from my properties file - Java Server Faces Questions
Problem to print from my properties file  Hi, I am a new user of this site. It is very interesting. So this is my problem: I have a jsp file where i try to print some messages from my properties file but when i execute
Sort file data and write into another file
Sort file data and write into another file By sorting, you can arrange the data into meaningful order and analyze it more effectively. Here we have one file... and grade. The data is not properly arranged in the file. Now, we have to display
problem in sending data from one ip to another ip in JAVA
problem in sending data from one ip to another ip in JAVA  Hi guys . this is naveen kumar...i need a help. i want to connect one ip to another ip (like ping),after that i want send the data with my system(Ip) to another ip
Problem to print from my properties file - Java Server Faces Questions
Problem to print from my properties file  Hi, I am a new user of this site. It is very interesting. So this is my problem: I have a jsp file where i try to print some messages from my properties file but when i execute
Display data from xml file to Swings - Swing AWT
Display data from xml file to Swings  Hi, We are Preparing a stand alone application. Where the Swings is the front end. There will be only... clicking the buttons in swings it has to display 20 record in one shot in table

Ads