This may be the same problem I experienced several months ago after
downloading the JSDK2.1 to a Windows 95 test machine I have.  In attempting
to run Sun's examples that included a doPost, I recall that I was receiving
the "connection reset by peer" message using IE.  Since I had a hard time
believing that Sun's examples wouldn't run, my recollection is that I
reinstalled Windows (easy since my test machine is set up with DriveImage
and a virgin Windows 95), the JVM, and JSDK.  Anyway, the problem
vanished -- the examples ran fine, and I dropped chasing it.

If you're using Win 95/98, my suggestion is that you try Sun's examples in
their original form.  If they do not run, then try everything on another
machine.

Regards,
Paul King

-----Original Message-----
From: Matthew George <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: Tuesday, January 04, 2000 1:56 PM
Subject: Re: 43 entries in the archives, but I am still lost............


>Hi Nic Ferrier,
>
>Thank you for your suggestion. I tried out the code snippet that you had
suggested by making a servlet to contain that code and called it using <FORM
METHOD=POST ACTION="/servlet/Postexample"> in HTML. My servlet is
>
>import java.io.*;
>import javax.servlet.*;
>import javax.servlet.http.*;
>import java.util.*;
>
>
>public class Postexample extends HttpServlet {
> public void doPost(HttpServletRequest req,HttpServletResponse resp)
>                    throws ServletException, IOException
>{
>   resp.setContentType("text/html");
>   PrintWriter p=new PrintWriter(resp.getOutputStream());
>   p.println("<html><body><h1>Hullo!</h1></body></html>");
>   p.close();
>}
>}
>
>It still comes up with the error "Connection reset by peer". I believe that
this servlet runner came along with the jsdk2.1. That should mean that all
people using this would have the same error  or that I have missed some
patches. I also tried out the technique given in Jason Hunter's book 5 Th.
chapter where instead of writing to the PrintWriter returned by getWriter(),
the servlet first builds a ByteArrayOutputStream and then builds the
PrintWriter around it. The advantage of this method is that we will be able
to get the exact length of the output in bytes. The value that I have used
in code that I had sent earlier sets the content length in characters.
>
>If you have any more pointers on this , I would be grateful to receive
them.
>
>Regards
>Mathew
>
>
>>>> Nic Ferrier <[EMAIL PROTECTED]> 01/04/00 12:08PM >>>
>>>> Matthew George <[EMAIL PROTECTED]> 04-Jan-00 3:45:19 PM >>>
>
>>I tried the work arounds like writing the whole output to a
>>StringBuffer and then writing the StringBuffer to the PrintWriter.
>>I have used setContentLength() to the exact length of the
>>output and also tried with  exact length plus two as someone
>>suggested.
>
>You should not set the content length if you are having trouble. The
>easiest thing to do is try this:
>
>
>void doPost(HttpServletRequest req,HttpServletResponse resp)
>{
>   resp.setContentType("text/html");
>   PrintWriter p=new PrintWriter(resp.getOutputStream());
>   p.println("<html><body><h1>Hullo!</h1></body></html>");
>   p.close();
>}
>
>
>if that works then servletrunner is ok and it is your code.
>
>Check that you are flushing and closing buffers properly.
>
>
>
>
>Nic Ferrier
>
>___________________________________________________________________________
>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

Reply via email to