hi ,
kevin was write uploading is process of sending file from client to server.
for that u can have a simple jsp with a form with an special enctype.(it
may be ENCTYPE = MIME/binary-form data) i will send u exact page soon.
and a browse button using which client can select any of its system file
and send a file ( i will send u the example code later b/c at the moment
i am in office.)
so when client submit the form the servlet is invoked, in this servlet
u have to parse the binary data received from form , this can be done with
third party tool. and than u can save that file on the server as you wish.
i will soon send u the source code that will solve ur problem.
by
faisal parwani
>Hi everyone,
>
>Could someone direct me on how to upload text files in Servlets.
>I write this code to read the contents of the local system. In my office
>we have network, so I start Javawebserver at server. In other system I am
>trying upload that text file to server. But it is not working. Please
>direct me.
>
>import javax.servlet.*;
>import javax.servlet.http.*;
>import java.util.*;
>import java.io.*;
>import java.io.BufferedReader;
>
>public class FileReader1 extends HttpServlet
>{
>
> public void doGet(HttpServletRequest
>req,HttpServletResponse res)throws ServletException,IOException
> {
> res.setContentType("text/html");
> PrintWriter out=res.getWriter();
>
> File file=new File("c:/geethika/xml/abc.txt");
> try
> {
> BufferedReader in=new BufferedReader(new FileReader(file));
> //FileReader fr=new FileReader(file);
> //BufferedReader in=new BufferedReader(fr);
> String s;
> s=in.readLine();
> while (s!=null)
> {
> System.out.println("read: "+s);
> s=in.readLine();
> }
> in.close();
> }catch(Exception ee)
> {
> ee.printStackTrace();
> }
>
>
> }
>
>}
>
>
>Thanks in advance.
>