I have found the reason ... My code was the equivalent of :

URL url = new URL("http://localhost:8080/examples/snoop?param1=value1";);
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setUseCaches(false);
connection.setRequestProperty("Content-type",
"application/x-www-form-urlencoded");

PrintWriter out = new PrintWriter(connection.getOutputStream());
out.print("param2=value2");
out.close();
connection.connect();
connection.getInputStream().close();

And this throws an error. The problem is with the last line which works
fine with all other servlet engines but not Tomcat 3.3. If I change it
to :

connection.disconnect();

it now works fine. This probably means that when the connection is
closed it tries to close the underlying input stream and does not verify
if it is already closed (or something like this).

Thanks and sorry for the trouble.
-Vincent

> -----Original Message-----
> From: Vincent Massol [mailto:[EMAIL PROTECTED]]
> Sent: 21 December 2001 16:15
> To: 'Tomcat Users List'
> Cc: 'Larry Isaacs'
> Subject: RE: [Tomcat 3.3] Strange behaviour w/ mixed POST/GET request
> 
> 
> 
> > -----Original Message-----
> > From: ian silvester [mailto:[EMAIL PROTECTED]]
> > Sent: 21 December 2001 15:18
> > To: Tomcat Users List
> > Subject: Re: [Tomcat 3.3] Strange behaviour w/ mixed POST/GET
request
> >
> > Hmm.
> >
> > The fact that you only get this behaviour in 3.3 suggests very
> strongly a
> > problem in that release. Is there any reason why you can't use a
> different
> > release and avoid the error?
> >
> 
> Because in the framework I am working on (Jakarta Cactus), I need to
> support all servlet engines (including Tomcat 3.3) :-)
> 
> > That aside, I have seen this error under different circumstances -
> doing a
> > response.sendredirect in a JSP _after_ having already output HTML to
> the
> > browser. For this to error is fair enough - its supposedly outside
the
> > HTTP
> > spec. to send redirects after having started outputting HTML (in
ASP,
> MS
> > being the hand-holders that they are, attempting to do this throws a
> > runtime
> > error so as to avoid unexpected behaviour).
> >
> > Could your code be construed as doing something similar? If yes,
then
> you
> > cannot guarantee that it will work on all combintaions of browser
and
> > server.
> >
> 
> There is no sendredirect in my code but I may be doing something not
in
> the spec ... As suggested by Larry Isaacs, I'm going to open a bug in
> bugzilla with details on the test case. However, it is going to take
> some time as I need to extract the relevant portion from the code. I
> hoped someone was going to say something like : "yes, we know, we have
> an issue when you're sending parameter in the URL at the same time as
in
> the request body" ... :-)
> 
> In the meantime (before I finish extracting the code), some more
> information on the code logic (client side) :
> 
> 1/ open an http connection to Tomcat 3.3 using HttpURLConnection and
> read all returned data (with attached AutoReadHttpURLConnection class)
:
> 
>   HttpURLConnection connection = helper.connect(theRequest);
>   connection = new AutoReadHttpURLConnection(connection);
>   // Trigger the transfer of data
>   connection.getInputStream();
> 
> On the server side, some code is executed and a result is set in the
> application context.
> 
> 2/ open a second connection to the server using HttpURLConnection and
> get the test result (sent back as an ObjectOutputStream)
> 
> Repeat 1/ and 2/ for all the requests I mentioned in my previous mail
> (the mixed POST/GET one and the other GET ones).
> 
> Thanks
> -Vincent
> 
> > ian
> >
> > ----- Original Message -----
> > From: "Vincent Massol" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Friday, December 21, 2001 2:44 PM
> > Subject: [Tomcat 3.3] Strange behaviour w/ mixed POST/GET request
> >
> >
> > > I have a strange behaviour in Tomcat 3.3 that does not happen
either
> in
> > > Tomcat 4.x or in Tomcat 3.2.x (or any other servlet engine for the
> > > matter : Orion, Resin, WebLogic). It looks like voodoo for me and
I
> have
> > > trouble understanding what's happening.
> > >
> > > I am sending several different HTTP requests (using
> HttpURLConnection)
> > > to the server and depending on the order I get or do not get an
> error.
> > > When I get the error, it is the typical :
> > >
> > > Connection aborted by peer: JVM_recv in socket input stream read
> > > java.net.SocketException: Connection aborted by peer: JVM_recv in
> socket
> > > inp
> > > ut stream read
> > >    at java.net.SocketInputStream.socketRead(Native Method)
> > >
> > > I am doing one special request in which I send _both_ GET
parameters
> (in
> > > the URL) and parameters in the request body (POST method). The
other
> > > requests are only GET requests.
> > >
> > > If I call the mixed POST/GET request first, followed by the other
> GET
> > > requests then everything is fine. However, if I start by doing on
> GET
> > > request and then followed by the mixed POST/GET one, I get the
> > > connection aborted by peer error.
> > >
> > > Any idea ? Any known issues with mixed POST/GET requests ?
> > >
> > > Thanks a lot for any hint as I'm beginning to tear my hair ... :-)
> > > -Vincent
> > >
> > >
> > >
> > > --
> > > To unsubscribe:
> <mailto:[EMAIL PROTECTED]>
> > > For additional commands:
> <mailto:[EMAIL PROTECTED]>
> > > Troubles with the list:
> <mailto:[EMAIL PROTECTED]>
> > >
> > >
> >
> >
> >
> > --
> > To unsubscribe:
<mailto:[EMAIL PROTECTED]>
> > For additional commands:
<mailto:[EMAIL PROTECTED]>
> > Troubles with the list:
<mailto:[EMAIL PROTECTED]>
> >




--
To unsubscribe:   <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>

Reply via email to