Я использую сервлет, который передает параметр String другому сервлету в другой удаленной системе, чтобы получить ответ XML от этого удаленного сервлета.
Это прекрасно работает, когда я пытался подключиться к этому удаленному сервлету с моего локального ПК.
Но я получаю сообщение об ошибке java.net.SocketException: Unexpected end of file from server
, когда выполняю то же самое с другого сервера.
Ошибка:
2011-06-04 11:27:24,305 INFO [STDOUT] strURL in Inventry --> http://1**.1**.**.27:7777/GatewayServlet
/Status?Str=Inventory&PARTNUM=200A104%27%2C%27200A112%27%2C%27200A114%27%2C%27200A113%27%2C%27200A117%27%2C%27200A120%27%2C%27240A503%27%2C%27200A132%27%2C%27200A128%27%2C%27200A124
2011-06-04 11:28:06,243 ERROR [STDERR] java.net.SocketException: Unexpected end of file from server
2011-06-04 11:28:06,243 ERROR [STDERR] at sun.net.www.http.HttpClient.parseHTTPHeader(Unknown Source)
2011-06-04 11:28:06,243 ERROR [STDERR] at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
2011-06-04 11:28:06,243 ERROR [STDERR] at sun.net.www.http.HttpClient.parseHTTPHeader(Unknown Source)
2011-06-04 11:28:06,243 ERROR [STDERR] at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
2011-06-04 11:28:06,243 ERROR [STDERR] at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
2011-06-04 11:28:06,243 ERROR [STDERR] at com.cim.web.servlet.DBGatewayServiceServlet.processRequest(DBGatewayServiceServlet.java:52)
2011-06-04 11:28:06,243 ERROR [STDERR] at com.cim.web.servlet.DBGatewayServiceServlet.doGet(DBGatewayServiceServlet.java:113)
2011-06-04 11:28:06,243 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
2011-06-04 11:28:06,243 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
2011-06-04 11:28:06,243 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
2011-06-04 11:28:06,243 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
2011-06-04 11:28:06,243 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
2011-06-04 11:28:06,243 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
2011-06-04 11:28:06,243 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
2 011-06-04 11:28:06,243 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
2011-06-04 11:28:06,243 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
2011-06-04 11:28:06,243 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
2011-06-04 11:28:06,243 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
2011-06-04 11:28:06,243 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
2011-06-04 11:28:06,243 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
2011-06-04 11:28:06,243 ERROR [STDERR] at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
2011-06-04 11:28:06,243 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
2011-06-04 11:28:06,243 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
2011-06-04 11:28:06,243 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
2011-06-04 11:28:06,243 ERROR [STDERR] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
2011-06-04 11:28:06,243 ERROR [STDERR] at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
2011-06-04 11:28:06,243 ERROR [STDERR] at java.lang.Thread.run(Unknown Source)
Код в моем сервлете (клиент):
if(queryString.equals("Inventory")) {
String partNum = (String)session.getAttribute("PARTNUM");
String locId = (String)session.getAttribute("locids");
strURL = strURL+"/InventoryStatus?queryStr=Inventory&PARTNUM="+partNum;
URLConnection dbGatewayURL = new URL(strURL).openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(dbGatewayURL.getInputStream()));//--This is line 52 Mentioned in Error above
StringBuffer responseData = new StringBuffer();
String line="";
while((line = in.readLine()) != null) {
responseData.append(line);
}
String result =responseData.toString();
request.setAttribute("inventryStock",result);
RequestDispatcher rd=request.getRequestDispatcher ("inventryStatus.jsp?resp=Yes");
rd.forward(request, response);
}