Here's a few things to try. In your applet, get the input stream before you close the output stream. Send the content length to the servlet - use a ByteArrayOutputStream to store the object(s), send the length, then send the byte[]. Aaron > -----Original Message----- > From: Narendra Acharya [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, April 07, 1999 11:41 PM > To: [EMAIL PROTECTED] > Subject: EOF Exception in Applet to Servlet Communication > > > Hi everybody, > > We r trying to send objects from applet to servlet. both the > applet and servlet code is given > below. we are using jrun2.3 on Netscape Enterprise Server 3.6 > on NT 4.0 > > we are getting some EOF Exception while creating an > ObjectInputStream from > HttpServletRequest.getInputStream(). i've included the > stacktrace below. We tried with > JavaWebServer 1.1.3 on Windows 95 and it is working fine > without any exception. > The problem is only with jrun. > We also checked on Solaris 2.6, JRun2.3 and NES 3.5.1 > > We've developed a prototype of our project on JWS 1.1.3 on > Win 95 but now we r facing the > problem mentioned below while "porting" it to solaris 2.6 and > JRUN 2.3 (on NES 3.5.1) > > luv > narendra > > <Applet code snippet Begin> > try > { > URL action = new URL(<pathname>); > URLConnection url = action.openConnection(); > > url.setDoInput(true); > url.setDoOutput(true); > url.setUseCaches(false); > url.setRequestProperty("Content-type", > "application/x-www-form-urlencoded"); > > boolean first = true; > > // Write out post data > ObjectOutputStream out = new > ObjectOutputStream(url.getOutputStream()); > out.writeObject("values"); > out.flush(); > out.close(); > > // Get response > ObjectInputStream in = new > ObjectInputStream(url.getInputStream()); > > String szErrMessage = (String)(in.readObject()); > > System.out.println("error = " + szErrMessage); > in.close(); > > } catch(Exception e) > { > e.printStackTrace(); > } > <Applet code snippet End> > > <Servlet code snippet Begin> > String szErrorMessage = new String(""); > ObjectOutputStream oos = null; > ObjectInputStream ois = null; > try > { > > ServletInputStream sis = req.getInputStream(); > System.out.println("before object input stream"); > ois = new ObjectInputStream(sis); > System.out.println("after object input stream"); > > oos = new ObjectOutputStream(res.getOutputStream()); > System.out.println("after object output stream"); > > String input = new String(); > input = (String)(ois.readObject()); > > oos.writeObject("output"); > oos.flush(); > > }catch(Exception ex) > { > ex.printStackTrace(); > System.out.println("ex = " + ex.getMessage()); > } > > <Servlet code snippet End> > > Reading POST parameters: java.lang.IllegalArgumentException > java.io.StreamCorruptedException: Caught EOFException while > reading the stream header > at > java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:727) > at > java.io.ObjectInputStream.<init>(ObjectInputStream.java:165) > at QuotLoginServlet.doPost(Compiled Code) > at > javax.servlet.http.HttpServlet.service(HttpServlet.java:538) > at > javax.servlet.http.HttpServlet.service(HttpServlet.java:611) > at com.livesoftware.jrun.JRun.runServlet(Compiled Code) > at > com.livesoftware.jrun.JRunGeneric.handleConnection(JRunGeneric.java) > at > com.livesoftware.jrun.JRunGeneric.handleProxyConnection(JRunGe > neric.java) > at > com.livesoftware.jrun.service.proxy.JRunProxyServiceHandler.ha > ndleRequest(JRunProxyService > Handler.java) > at > com.livesoftware.jrun.service.ThreadConfigHandler.run(Compiled Code) > > luv > narendra > > > Don't be afraid of pressure. Remember that pressure is > what turns a lump of coal into a diamond. > ___________________________________________________________________________ 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
