我有一个 client_servlet ,通过它我必须连接到 server_servlet 。这个代码在单个用户使用时工作正常,但是它提供了一个HTTP尝试由2个用户使用时状态500错误。
以下代码位于 client_servlet 中,servletURL中给出了server_servlet的url。请帮助使这个工作为多个用户
if (!( request.getParameter("RFQ") == null )) {
String result = "";
try {
String servletURL = http://localhost:8080/Trapii/retservlet_server" ;
String query = "firstCurr=" + ls_firstCurr
+ "&secondCurr=" + ls_secondCurr
+ "&tenor=" + ls_tenor
+ "&direction="+ ls_direction
+ "&firstCurrAmt=" + ls_firstCurrAmt
+ "&rate=" + ls_price
+ "&trapi=" + ls_msg
+ "&userid=" + ls_userid
+ "&sessionid=" + ls_sessionid
+ "&RFQ=RFQ";
System.out.println("query string is : " + query);
String charEncoding = "iso-8859-1";
URL sendUrl = new URL(servletURL);
System.out.println("This is RFQ");
//HttpURLConnection conn = (HttpURLConnection) sendUrl.openConnection();
HttpURLConnection conn = (HttpURLConnection)sendUrl.openConnection();
conn.setDoOutput(true);
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Length", Integer.toString(query.length()));
conn.getOutputStream().write(query.getBytes(charEncoding));
System.out.println("Going to get the InputStream Object");
InputStream inputStream = conn.getInputStream();
BufferedReader in = new BufferedReader(new InputStreamReader(inputStream));
System.out.println("Reading the ouput received from servlet");
result = in.readLine();
}
catch (Exception e1) {
System.out.println("RFQ Error");
e1.printStackTrace();
}
ls_msg = result;
ls_sessionid = session.getId();
}