Question: Problem with appending data to the end of file

Ads

 
 
 

Share on Google+Share on Google+

Stany Simon
Problem with appending data to the end of file
0 Answer(s)      4 years and 11 months ago
Posted in : JSP-Servlet

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.

Ads
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
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
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 are available already and you need to write the text at the end of line you may to use
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
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
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
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
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
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
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
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
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 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
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 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
application context file problem
application context file problem  how to configure junit application context file with struts........? it is not finding sessionfactory method
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
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
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
Write data in doc file
Write data in doc file  How to write data or string in word file
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 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
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
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
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
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
Tutorials   
Java Spring Hibernate Struts Training fat image from db fat image from db fat image from db fat image from db unable to get value returned from javascript variable in page How to change image size before adding to mysql using jsp Design a registration.jsp page with input for user registration details Cart Quantity jsp servlet coding issue servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? image pdf marking pdf marking Multiple image upload using JSP Read code from excel sheet and upload into database using JSP Student java about search engine Convert BLOB to PDF and save it to a location how to copy files from remote to local machine using SFTP SSL in java? Like Team viewer Socket and Servert -Jsp how to copy files from remote location to local using java? How To Store Multilple Images In MySQL database dynamically with image uploader and then retrieve them in image gallery using java how to create SOAP based web service in java? how to fetch data from mysql database table and draw a bar chart on that data using in jsp how to create users in LDAP using java? how to authenticate user using TIVOLI api in java? how to create users using IBM Tivoi API in jsp/servelet? Java/J2ee Please explain this code as many packages and classes are unknown to me .! how to download the uploaded folder files using jsp Login Query image is display from path of mysql database please reply the code to store dynamic fields in database? Reloading issue in jsp How to get Button Id ? calling one jap page from another jsp page login login Problem to get connection from DAO class to JDBC Page Loading Time Fix table's column's name row(1st row of the table) so that it does not move up when the table is scrolled up to view more rows below Sending hidden values

Ads

 
Advertisement null

Ads