hello guys, i am writing applet-servlet communication application, i am getting this error, which i am unable to resolve after digging into google also, hope someone here could help me get rid of the error. thanks in advance
java.io.EOFException at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2279) at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2748) at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:780) at java.io.ObjectInputStream.<init>(ObjectInputStream.java:280) at NewServlet.doPost(NewServlet.java:112) at NewServlet.doGet(NewServlet.java:69) at javax.servlet.http.HttpServlet.service(HttpServlet.java:689) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684) at java.lang.Thread.run(Thread.java:619)
also another thing : when i do System.out.println(" Content Length = " + request.getContentLength()); it shows -1
and at applet side when i write JOptionPane.showMessageDialog(this,"Priting buf length \n" + buf.length,"Testing!!" , JOptionPane.WARNING_MESSAGE); it shows 501 while JOptionPane.showMessageDialog(this,"Priting con length \n" + con.getContentLength(),"testing!!" , JOptionPane.WARNING_MESSAGE); shows 234
Michael Ku
Ranch Hand
Joined: Apr 20, 2002
Posts: 510
posted
0
You are attempting to connect to a servlet without using HTTP. Instead of URLConnection use HttpUrlConnection.
I am not sure, but why are you writing the object to a ByteArrayOutputStream before streaming it across thew wire?
Just get a handle to the stream from the HttpUrlConnection and create your object stream with this. Then write your object to this stream.
I thin this is the nature of your problem.
Gurbhej Singh Dhillon
Greenhorn
Joined: Oct 04, 2007
Posts: 10
posted
0
yes i was using that before only, but was getting same here, untill someone suggested to use ByteArrayOutputStream + DataOutputStream to set the content length, which might be the reason for EOF Exception. both ways none is working
Gurbhej Singh Dhillon
Greenhorn
Joined: Oct 04, 2007
Posts: 10
posted
0
does any1 has an answer to my question ??.. thought newbies questions would be answered over here, alas
What you are coding is not a daily thing for most people, unlike most questions/problems that are posted. In order to help you a person would either have to receate your problem and debug or search the net for an example that works and compare it to your problem. This is a lot of work to ask other people to do on your behalf...
Michael Ku
Ranch Hand
Joined: Apr 20, 2002
Posts: 510
posted
0
Here is an example I found on the net for sending an object across the wire. Please compare it to your code.
and the code the de-serialize the object on the server side
Val�ry Urbain
Greenhorn
Joined: Oct 21, 2007
Posts: 11
posted
0
Originally posted by Michael Ku: Here is an example I found on the net for sending an object across the wire. Please compare it to your code.
Excellent! Not that I want to be picky, but you should have pointed out from where you have got this code..
Laurentiu Bold
Greenhorn
Joined: Oct 15, 2007
Posts: 11
posted
0
Michael,
Don't jump to the conclusion . Gurbhej will probabily use your example and if it's what he needs, he will thank you if you want it... but "picky" was Val�ry Urbain who might be (or not) the author of your found source code.
Thank you [ October 22, 2007: Message edited by: Laurentiu Bold ]
Michael Ku
Ranch Hand
Joined: Apr 20, 2002
Posts: 510
posted
0
Laurentiu, thank you for pointing out my mistake. I have deleted my post.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.