Chinaunix

标题: applet与servlet通信的时候遇到了一个问题 [打印本页]

作者: fxwolf    时间: 2006-01-23 20:59
标题: applet与servlet通信的时候遇到了一个问题
大家好:

我在做applet与servlet通信的时候遇到了一个问题,请各位朋友帮忙解决一下。

问题描述如下:
在applet端部分代码
urlServlet = new URL(url);
conn = urlServlet.openConnection();
conn.setDoInput(false);
conn.setDoOutput(true);
conn.setUseCaches(false);
conn.setDefaultUseCaches(false);
conn.setRequestProperty("Content-Type", "application/octet-stream";
ObjectOutputStream outputToHost = new ObjectOutputStream(
conn.getOutputStream());
// serialize the object
outputToHost.writeObject(defaultClientEnv);

outputToHost.flush();
outputToHost.close();



在servlet端部分代码
ServletInputStream inStream = request.getInputStream();

inputFromClient = new ObjectInputStream(inStream); //这行代码出错。

Object obj = inputFromClient.readObject();

出错提示:

java.io.EOFException
at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2232)
at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:269
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:750)
at java.io.ObjectInputStream.(ObjectInputStream.java:26
at finance.servlets.TransmitServlet.doPost(Unknown Source)
at finance.servlets.TransmitServlet.doGet(Unknown Source)
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.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:17
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:14
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:86
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
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:595)



希望大家能帮我解决。。。

先谢谢了。




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2