Check this snippet from one of my servlets, I used it to display a document,
wich is read when it is required.
to read and/or write text files you use FileReader and FileWriter, anyway,
check this code, I think it is clear.
Regards,
public boolean copyFile(PrintWriter out, String dochtml)
{ // "out" is the servlet�s response object.
try
{
File inputFile = new File("C:\\SpyWebSite\\calidad\\" + dochtml);
FileReader in = new FileReader(inputFile);
int c;
while ( (c = in.read() ) != -1 )
{ System.out.print((char) c); out.print( (char)c ); }
in.close();
out.close();
return true;
}
catch (Exception e)
{ System.out.println("Error en la carga del archivo.." + e ); return
false; }
}
�������������������������������������
Jaime Santana Ruelas
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]
ICQ: 19745928
�������������������������������������
> -----Mensaje original-----
> De: sachin rameshrao zingade [SMTP:[EMAIL PROTECTED]]
> Enviado el: mi�rcoles 22 de diciembre de 1999 1:24
> Para: [EMAIL PROTECTED]
> Asunto: Reading & Writting files with Servlets
>
> Hi
> I have a problem,
> I am using JWS2.0,I want to read
> I have a text file which contains many names,the HTML file takes a name
> from
> the TextField & on submit it initiates the servlet,the Servlet
> should open the text file and check for the name if it exists then give
> some
> message.
>
> To read and write I am facing the problem
>
> Can any send me the solution or any suggestion?
>
> Sachin
>
>
>
> ----- Original Message -----
> From: Krishna Prasad Kalluri <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, December 22, 1999 9:01 AM
> Subject: Re: Servlets and XML
>
>
> > hi vijay
> > I think you didn't place the second servlet in a proper directory or
> there
> may a class name mismatch .
> > So try by properly placing in the directory where you generally place
> the
> servlets and see it
> > regards
> > prasad
> >
> > Vijay Bulusu wrote:
> >
> > > Hi All,
> > >
> > > I need urgent information on the following.
> > >
> > > The architecture of my application is as below:
> > > HTML -> Servlets -> XML -> Database
> > >
> > > For this purpose, I am using IBM's XMLParser for java: XML4J.
> > >
> > > The first servlet that I invoke asks the user to enter the path of the
> file (XML File). The servlet then sends this output to another servlet
> that
> displays the contents of this file in a HTML table format.
> > >
> > > I am using Apache web server on windows platform to test this out. As
> soon as the second servlet is called I am getting an error message saying:
> > >
> > > "Internal Server Error".
> > >
> > > I checked up the logs of the JServ module in which I found the
> following
> message:
> > >
> > > java.lang.NoClassDefFoundError: org/w3c/dom/Document
> > > at
> org.apache.jserv.JServConnection.run(JServConnection.java:365)
> > > at java.lang.Thread.run(Thread.java:479)
> > >
> > > Please help me with this problem.
> > >
> > > Regards,
> > > Vijay.
> > >
> > >
> __________________________________________________________________________
> _
> > > To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> body
> > > of the message "signoff SERVLET-INTEREST".
> > >
> > > Archives: http://archives.java.sun.com/archives/servlet-interest.html
> > > Resources:
> http://java.sun.com/products/servlet/external-resources.html
> > > LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
> >
> >
> __________________________________________________________________________
> _
> > To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> body
> > of the message "signoff SERVLET-INTEREST".
> >
> > Archives: http://archives.java.sun.com/archives/servlet-interest.html
> > Resources: http://java.sun.com/products/servlet/external-resources.html
> > LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
> __________________________________________________________________________
> _
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html