Home Answers Viewqa Java-Beginners NOT ABLE TO MAKE A NEW FILE IN SERVLET

 
 


prateek gupta
NOT ABLE TO MAKE A NEW FILE IN SERVLET
1 Answer(s)      10 months ago
Posted in : Java Beginners

What is the error in my code? It is not making a new file which contains the string values coming from a HTML page. Any help appreciated.

Code is-:

package myprogram;

import javax.servlet.http.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.RequestDispatcher;

public class LoginPageServlet extends HttpServlet
{
    public void doGet(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException
    {
        res.setContentType("text/html");

        String fname=req.getParameter("p1");
        String lname=req.getParameter("p2");

        PrintWriter out=res.getWriter();

        out.println("HI from Login Page Servlet");
        out.println(fname);

        try{

        File file=new File("C://abc.xml");

        FileWriter fr=new FileWriter(file,true);

        BufferedWriter br=new BufferedWriter(fr);

        br.write("First Name" +fname + " Last name is " + lname);

        br.newLine();       

        out.println("File is created successfully");

        br.close();
        }

        catch(Exception e)
        {
            e.printStackTrace();

        }


    }


}
View Answers









Related Pages:
New to JSP..need help to make & run a JSP program.
New to JSP..need help to make & run a JSP program.  Hi, I have installed Tomcat 5.5 on my system. Plz help me to make a simple JSP program...:\apache-tomcat-5.5\lib.*; Also out the servlet api.jar file inside the lib folder
To Determine whether the Session is New or Old
To Determine whether the Session is New or Old       In this program we are going to make one servlet on session in which we will check whether the session is new or old
new
new   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ <%@page contentType="text.... * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O
New to Java?
New to Java?       If you are new to Java technology and you want to learn Java and make career... used to run Servlet and JSP. It is not merely limited to application server
How to make a gzip file in java.
Make a gzip file from any given file. In this tutorial, we will discuss how to create GZIP file by using GZIPOutputStream class. ... {       File oldfile = new File(sourcefile
FILE
args[]) { try { File file=new File("Name.txt"); FileReader f=new FileReader(file... static void main(String args[]) { try { File file=new File("Name.txt"); FileReader f=new FileReader(file); int ch; while
file
file  hi i want read special line of file. what am i doing ? I write a code but is false in this programm i want make tree with java but i should read data from file. please help me! void maketree(BtNode root,int i) throws
Error 500-Server are not find the jar file in the program of upload the file - JSP-Servlet
); // Create a new file upload handler System.out.println(isMultipart); DiskFileUpload..."); System.out.println(item.getName()); File cfile=new File(item.getName()); File tosave=new File(getServletContext().getRealPath("/"),cfile.getName
How to make a chain, make a chain, chain
easy by this example, it has some important instruction to make it so follow now. New File: Create file size with any size. Pen Tool: Choose "565656... How to make a chain      
How to make bubbles, make bubbles, bubbles
to make it easily to draw. New File: First take colored background file. Draw... How to make bubbles      ... Overlay, use same both settings as given below. Duplicate: Now make
make a file password protected
make a file password protected  I am trying to write Java code for creating a file of any type (either text,csv,or any other format). What I need is : The file generated should be zipped and password-protected. When I try to open
How to make a bone, make a bone, a bone
How to make a bone       This example bone design example, It is very easy. If you are looking for, please follow now. New File: Create a new file. Rounded rectangle
how make excel
how make excel  how make excel spreadsheet IN JAVA. please send...:/hello.xls" ; HSSFWorkbook hwb=new HSSFWorkbook(); HSSFSheet sheet = hwb.createSheet("new sheet"); HSSFRow rowhead= sheet.createRow((short)0
How To Make Executable Jar File For Java P{roject - Java Beginners
How To Make Executable Jar File For Java P{roject   Hello Sir I want Help to make Executable File for java Project How I can Make it?  Hi...(); File folder = new File("C:\\html"); File[] files
uploade file in servlet
uploade file in servlet  how to uploade a file in servlet  ...,formDataLength); totalBytesRead += byteRead; } String file = new String(dataBytes..., boundaryLocation)).getBytes()).length; saveFile="C:/UploadedFiles/"+saveFile; File ff = new
How to make a list from file text in J2ME - Java Beginners
How to make a list from file text in J2ME  I was trying to make a method that read file from text and make a list of it, I have tried ReadHelpText method and want to make some improvement, I've tried like this private String
FILE UPLOADING - JSP-Servlet
FILE UPLOADING  Hi , I want Simple program for file upload using html and servlet plese help me  hi friend pls try this code...())!='\n'); byte[] b=new byte[Integer.parseInt(sz)]; int cntr=0; while
Java file create new file
Java file create new file This section demonstrates you how to create a new... of these tools, you can can easily create a new empty file. Now for this task, we have used the method createNewFile() of boolean type which creates a new empty file
How to make a transparent text
How to make a transparent text Learn how to make a transparent text effect with this example. New File: Take a new file with white...) and make formatting as looking here. Write Text: Now write your text
Create a new zip file in ZipArchive.
Creating a new Zip file in ZipArchive For creating zip file, use zipArchive () class. Create a new zip file in ZipArchive. Use the conditional statement... will generate a new zip file, in case of failure, it will print failed in creating
Dbclass.java file - JSP-Servlet
= "select empid from new_user"; stmt = con.createStatement... password from new_user"; stmt = con.createStatement(); rs... vsql="insert into new_user values(?,?,?)"; pstmt=con.prepareStatement(vsql
To make java exe or runnable file
To make java exe or runnable file   Helo sir i make a java application.I need to help how run application direct in pc i.e how it packaged, .exe file or setup file
New Features in JDBC 4.0
to make his implementation as a Service then he has to maintain the file name... New Features in JDBC 4.0      ... the Results. Some of the new set of features which come along with Mustang
write to file from servlet - JSP-Servlet
write to file from servlet  Hi, I have a jsp file where I input data and retrive data through servlet. However; when I edit data it is not showing right data on the web site. I am also trying to write this data to file
How To Create a New File
How To Create a New File In this section we will discuss about how to create a new file in Java. A Computer File is a storage of data. In this file we can.... Such as, File.createNewFile() method creates the new file. java.io.File creates the new
new 2
new 2  <%@page import="java.util.ArrayList"%> <%@page...;/code> and * <code>POST</code> methods. * * @param request servlet request * @param response servlet response * @throws ServletException
Java file new line
Java file new line In this section, you will learn how to write the text in new line of text file. Description of code: The package java.io.* has provide... main(String[] args) throws Exception { File f = new File("C:/file.txt
Opening a new window in Echo3
and servlet mapping into the deployment descriptor file web.xml <!DOCTYPE... Opening a new window in Echo3   ... will create a new Window. To create this example we have created two class files
How to make a 3D text, make a 3D text, a 3D text
will guide you to make it. New File: Take a new file with any size as you like. Text Formatting: Choose Horizontal type tool (T key) and make formatting then write... How to make a 3D text      
How to Make a Pdf and inserting data
which will help us to make a pdf file.  The logic of the program..., formDataLength); totalBytesRead += byteRead; } String file = new...;.pdf")); document.open(); document.add(new Paragraph(file
Multiple file Uploading - JSP-Servlet
Multiple file Uploading   Hello everyone I am using jsp and my IDE...() for servlet jsp threw exception org.apache.jasper.JasperException: Unable to compile class for JSP: An error occurred at line: 9 in the generated java file
How to make a grass text, make a grass text, grass text
How to make a grass text       Come to know how to make a grass text effect. New File: Take a new file with any size as you want. Text Formatting: Select Horizontal
How to make a valentine card
it. Follow now step by step instruction to make it. New File: Take a new file... Horizontal type tool (T key) and make formatting, click on the file... How to make a valentine card Learn a easy technique to make
How to make a diamond necklace, make a diamond necklace, diamond necklace
How to make a diamond necklace       This tutorial will give you instruction to make draw a diamond necklace, so follow all the steps to make similar. New file: First take a new
How to make a gel text, make a gel text, a gel text
How to make a gel text       This example will help you to draw a gel text effect, it is very easy to make. New File: Take a new file with any size as you want. Effects: Go
How to make text effect
How to make text effect We can make too many text effect in the photoshop, this text effect is one of them. Let's start... New File: Take a new File and adjust the file size as you need. Write Text: Select Horizontal Type
Getting file size - JSP-Servlet
+= byteRead; } String file = new String(dataBytes); //for saving the file...); File up = new File(saveFile); out.println(up.length()+" bytes...; // creating a new file with the same name and writing the content in new
Upload and download file - JSP-Servlet
); totalBytesRead += byteRead; } String file = new String(dataBytes); String... = DriverManager.getConnection(connectionURL, "root", "root"); File f = new File(saveFile); psmnt = connection.prepareStatement("insert into file(file_data) values(?)"); fis = new
How to make an animated blast, make an animated blast, animated blast
blast. New File: Take a new file with black background. Make a Bomb: Choose "FF5863" color and Pen tool (P key) to make a bomb shape... How to make an animated blast     
How to make a closing eyes, make a closing eyes, closing eyes
ready with this file by clicking bottom of the toolbar to make animation. You... in the every new frame so make complete animation as I have done here... How to make a closing eyes     
how to upload a file - JSP-Servlet
, totalBytesRead,formDataLength); totalBytesRead += byteRead; } String file = new...:/"+saveFile; File f = new File(saveFile); FileOutputStream fileOut = new... for uploading a file ...also related jar files related if their....please help me
How to make a piece of a tree
How to make a piece of a tree You can design a piece of a tree by following some simple steps that are given in this example to make it easily. Let's start Take a New File: We have to take a new file to modify
How to make a snow text effect
How to make a snow text effect Apply this example to make a snow text effect perfectly. New File: Take a new black background...) and make formatting to write text as here. Circle shape: Take a new
JSP file download - JSP-Servlet
JSP file download  Hi! I am saving (webapp/docs/sample.docx) path of the word file in database. when i want to download that file i am eliminating that file path using path.subString(16).. upto docs/. when i am clicking
How to make a colorful text, make a colorful text, colorful text
How to make a colorful text       You can learn here a color full text effect, this example. New File: Create a new file with any size. Write Text: Choose any color
How to make an animation in the text, make an animation in the text, an animation in the text
noise effect should be on new layer to make animation easily. You should... How to make an animation in the text   ..., in this example we are going to make animation in the text that is so easy
How to make a dropping text, make a dropping text, dropping text
been released. I hope you will like it so follow now. New file: Create a new... a new layer and choose Brush tool (B key) then make settings to draw as here... How to make a dripping text     
How to make a honey text, make a honey text, honey text
text will convert into a selection then make copy. New File: Now take a new file and paste your copied text as up. Bevel and Emboss: Use layer... them. New File: First take a new layer with any size as you need
How to make a text effect.
text effect in the Photoshop, so you can use any option for that. New File: First take a new file, adjust the file size as you want. Write Text: Select... How to make a text effect.     
How to make a torn picture
File: Take a new file with increased size as your picture size, past you... and past now in you new file as given below. You will have this picture... How to make a torn picture You might have seen a torn paper

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.