You can try this:
resp.setContentType("text/html");
PrintWriter out = resp.getWriter();
// Create the Network URL object to which I want to connect
// you may need to tweak this to be the full URL to the file you are
attempting to read
URL location = new URL("sentfile");
// Open the URL via openStream method of URL class into an InputStream
BufferedReader in = new
feredReader(
new InputStreamReader( location.openStream() ) );
String inputLine;
// Simultaneously read in and print
while ((inputLine = in.readLine()) != null) {
out.println(inputLine);
// or you can do some other processing...
out.flush();
}
// Close the InputStream
in.close();
// Always close the output stream as well
out.close();
Good luck,
--Will
------------------------------- __ \/_
William C. Kallander (' \`\
Software Engineer _\, \ \\/
LizardTech, Inc. /`\/\ \\
\ \\
National Building; Suite 200 \ \\/\/_
1008 Western Avenue /\ \\'\
Seattle, Washington 98104 __\ `\\\
206.652.5211 /|` `\\
206.652.0880 (Fax) \\
[EMAIL PROTECTED] \\ ,
------------------------------- `---'
"TANSTAAFL"
- Robert Anson Heinlein
----- Original Message -----
From: Venkat Gujjula <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, 22 October 1999 1:08 PM
Subject: Re: Reading a document from a html form!
> I am new to servlets. I want to read document from html form when sumbit
> button is pressed.
> I am getting only file name, not its content. Andy Bailey, can you help me?
>
> Here is the html and doPost methods I experimented with:
>
> HTML:
>
> <html>
> <form action="/servlet/filereading" method="POST" >
> Attach File: <input name="sentfile" type="file"> <br>
> <
input name="send" type="submit">
> </form>
> </html>
>
>
> Servlet "doPost" method:
>
> public void doPost(HttpServletRequest req, HttpServletResponse
resp)
> throws ServletException, IOException
> {
> resp.setContentType("text/html");
> PrintWriter out = new PrintWriter(resp.getOutputStream());
>
>
> out.println("<HTML>");
> out.println("<HEAD><TITLE>fileread
Output</TITLE></HEAD>");
> out.println("<BODY>");
>
> out.println(req.getParameter("sentfile"));
>
> out.println("</BODY>");
> out.println("</HTML>");
> out.close();
> }
>
> Thanks in advance,
> venkat
>
>
___________________________________________________________________________
> 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