ur doGet or doPost is returned and the streams are obsolete by the time u
try to
read the object.
see if u are doing the read in the same thread and not in a thread other
than doGet.

----- Original Message -----
From: Anil Kumar <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, March 11, 2002 10:26 PM
Subject: Applet-Servlet Communication problem. - Urgent Solution required


> Hi All,
>
>   I have the following code. I keep getting EOF exception  on the server
> side. Advice.
>
>
>
> CODE:
>
> public Object serialize(Object obj, URL url, String s) throws
> ConnectException, SocketException, IOException {
>         Object obj1 = null;
>
>
>         try {
>             URL url1 = new URL(Controller.codeBase, "/servlet/" + s);
>             URLConnection urlconnection = url1.openConnection();
>             urlconnection.setDoOutput(true);
>             urlconnection.setDoInput(true);
>             urlconnection.setDefaultUseCaches(false);
>
>
urlconnection.setRequestProperty("Content-Type","application/octec-stream");
>             ObjectOutputStream objectoutputstream = new
> ObjectOutputStream(urlconnection.getOutputStream());
>                         objectoutputstream.writeObject(obj);
>             objectoutputstream.flush();
>             objectoutputstream.close();
>             ObjectInputStream objectinputstream = new
> ObjectInputStream(urlconnection.getInputStream());
>             obj1 = objectinputstream.readObject();
>             objectinputstream.close();
>         }
>         catch(ConnectException connectexception) {
>                 connectexception.printStackTrace();
>             throw connectexception;
>         }
>         catch(SocketException socketexception) {
>                 socketexception.printStackTrace();
>             throw socketexception;
>         }
>         catch(IOException exception) {
>                 exception.printStackTrace();
>             throw exception;
>         }
>                 catch(Exception exception) {
>             exception.printStackTrace();
>         }
>         return obj1;
>     }
>
>
>
> SERVER SIDE EXCEPTION
> java.io.EOFException: Expecting code
>         at java.io.ObjectInputStream.peekCode(ObjectInputStream.java:1075)
>         at
java.io.ObjectInputStream.readObject(ObjectInputStream.java:219)
>         at
java.io.ObjectInputStream.inputArray(ObjectInputStream.java:795)
>         at
java.io.ObjectInputStream.readObject(ObjectInputStream.java:280)
>         at
> java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:40
> 3)
>         at
java.io.ObjectInputStream.inputObject(ObjectInputStream.java:985)
>         at
java.io.ObjectInputStream.readObject(ObjectInputStream.java:284)
>         at
> java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:40
> 3)
>         at
java.io.ObjectInputStream.inputObject(ObjectInputStream.java:985)
>         at
java.io.ObjectInputStream.readObject(ObjectInputStream.java:284)
>         at
> java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:40
> 3)
>         at
java.io.ObjectInputStream.inputObject(ObjectInputStream.java:985)
>         at
java.io.ObjectInputStream.readObject(ObjectInputStream.java:284)
>         at
> java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:40
> 3)
>         at
java.io.ObjectInputStream.inputObject(ObjectInputStream.java:985)
>         at
java.io.ObjectInputStream.readObject(ObjectInputStream.java:284)
>         at QuoteFramesServlet.doPost(QuoteFramesServlet.java:62)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:278)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:330)
>         at sun.server.ServletState.callService(ServletInfo.java:771)
>         at sun.server.ServletInfo.callServletService(ServletInfo.java:314)
>         at sun.server.http.InvokerServlet.service(InvokerServlet.java:141)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:330)
>         at sun.server.ServletState.callService(ServletInfo.java:771)
>         at sun.server.ServletInfo.callServletService(ServletInfo.java:314)
>         at
> sun.server.http.HttpServiceHandler.handleRequest(HttpServiceHandler.j
> ava:384)
>         at
> sun.server.http.HttpServiceHandler.handleConnection(HttpServiceHandle
> r.java:187)
>         at sun.server.ServiceHandler.run(ServiceHandler.java:99)
> java.io.IOException: invalid content length
>         at
sun.servlet.http.HttpInputStream.finish(HttpInputStream.java:120)
>         at
sun.servlet.http.HttpInputStream.close(HttpInputStream.java:338)
>         at java.io.ObjectInputStream.close(ObjectInputStream.java:1300)
>         at QuoteFramesServlet.doPost(QuoteFramesServlet.java:140)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:278)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:330)
>         at sun.server.ServletState.callService(ServletInfo.java:771)
>         at sun.server.ServletInfo.callServletService(ServletInfo.java:314)
>         at sun.server.http.InvokerServlet.service(InvokerServlet.java:141)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:330)
>         at sun.server.ServletState.callService(ServletInfo.java:771)
>         at sun.server.ServletInfo.callServletService(ServletInfo.java:314)
>         at
> sun.server.http.HttpServiceHandler.handleRequest(HttpServiceHandler.j
> ava:384)
>         at
> sun.server.http.HttpServiceHandler.handleConnection(HttpServiceHandle
> r.java:187)
>         at sun.server.ServiceHandler.run(ServiceHandler.java:99)
>
>
>
>
> Client Side Exception
> java.io.FileNotFoundException:
> http://172.20.19.229:8080/servlet/QuoteFramesServlet    at
> java.lang.Throwable.<init>(Compiled Code)       at
> java.lang.Exception.<init>(Compiled Code)       at
> java.io.IOException.<init>(IOException.java:53)         at
> java.io.FileNotFoundException.<init>(FileNotFoundException.java:50)     at
> sun.net.www.protocol.http.HttpURLConnection.getInputStream(Compiled Code)
>
>
> Please advice.
>
> Thanks & Regards
> Anil
>
>
___________________________________________________________________________
> 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