Servlet接收手机传输过来的数据出现问题,急请高手帮忙解决。
手机发生代码:
hc = (HttpConnection)Connector.open(SERVICE_ADDRESS);
hc.setRequestMethod(HttpConnection.POST);
hc.setRequestProperty( "Content-Type ", "application/x-www-form-urlencoded ");
DataOutputStream dos=hc.openDataOutputStream();
dos.writeUTF(card.toString());
dos.flush();
dos.close();
Servlet接受代码:
DataInputStream din=new DataInputStream(request.getInputStream());
System.out.println(din.readUTF());
以上代码在本地机器上测试没问题。
就是部署到服务器上以后,无论如何Servlet老是接受不到手机传输过来的数据。
还请那位大虾指教下,明天要交活了,急啊
以下是Tomcat报的异常:
java.io.EOFException at java.io.DataInputStream.readUnsignedShort(DataInputStream.java:323)
at java.io.DataInputStream.readUTF(DataInputStream.java:572)
at java.io.DataInputStream.readUTF(DataInputStream.java:547)
at CardService.doPost(CardService.java:65)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:214)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:825)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ssConnection(Http11Protocol.java:738)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpo
int.java:526)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFol
lowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
ool.java:684)
at java.lang.Thread.run(Thread.java:619)
------解决方案--------------------我想问的是 你说的本机能测试通过 而到服务器上不能执行