|
 |
pro_java_server thread: Connectoin reset by peer: JVM_recv in socket input stream read
Message #1 by "William Yuen" <william.yuen@x...> on Wed, 22 Aug 2001 05:01:23
|
|
Dear all experts,
I have 2 program:
- ClientApp.java is a client side Java application
- ServletApp.java is a Java servlet running in Tomcat 3.2.3
When I try to open a URLConnection from ClientApp to request an object
create by the servlet, it is OK and no problem (see my remarked code in
both program).
But when I try to switch their job, ClientApp send an object to
ServletApp. The exception "Socket Exception: JVM_recv in socket input
stream read" occurs in the servlet side, and it seems that the servlet was
hasn't been called, because there is no "Hello" message in my console. It
looks where strange, because when I receive an object from the servlet
side.. there was no problem at all.
Do you guys have any clues on it ? I am running the serlvet on Tomcat
3.2.3.
Thanks a lot !
===== Code =====
>>>>>>>>ClientApp.java
import java.net.URL;
import java.net.URLConnection;
import java.io.*;
public class ClientApp {
URL url;
URLConnection conn;
Account acc;
public ClientApp() {
try {
url = new URL("http://localhost:8080/xmlasia/servlet/ServletApp");
conn = url.openConnection();
// try to send an object to servlet
acc = new Account("A1234", 12500);
conn.setDoOutput(true);
ObjectOutputStream out = new
ObjectOutputStream((conn.getOutputStream()));
out.writeObject(acc);
out.flush();
out.close();
/* try to receive object from servlet (it is OK !)
conn.setDoInput(true);
ObjectInputStream in = new
ObjectInputStream((conn.getInputStream()));
acc = (Account) in.readObject();
in.close();
System.out.println("A/C #:" + acc.getAccountNumber());
*/
} catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String args[]) {
ClientApp clientApp = new ClientApp();
}
}
>>>>>>>>ServletApp.java
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class ServletApp extends HttpServlet {
Account acc;
public void service(HttpServletRequest request,
HttpServletResponse response) {
System.out.println("Hello");
try {
// try to receive an object from application
ObjectInputStream in = new
ObjectInputStream(request.getInputStream());
acc = (Account) in.readObject();
in.close();
/* try to send object to application (OK !!)
acc = new Account("A1234", 12500);
ObjectOutputStream out = new
ObjectOutputStream(response.getOutputStream());
out.writeObject(acc);
out.flush();
out.close();
*/
} catch( Exception e ){
e.printStackTrace();
}
}
}
|
|
 |