Hi
I have an
applet and a
servlet. They use http and object-serialization. The communication between them works as long as I send objects only in one direction (either applet->servlet or servlet->applet). But when the servlet should return some objects straightly after receiving an object from the applet, the applet receives nothing.
Thanks
*********************************************************************************************
Applet Code (Method)
*********************************************************************************************
URL url = null;
URLConnection servletConnection = null;
Vector vStg = null;
try {
url = new URL("https://localhost:8080/servlet/vpl");
servletConnection = url.openConnection();
servletConnection.setDoInput(true);
servletConnection.setDoOutput(true);
servletConnection.setUseCaches (false);
servletConnection.setDefaultUseCaches (false);
servletConnection.setRequestProperty("Content-type","application/x-java-serialized-object");
ObjectOutputStream outputToServlet = new ObjectOutputStream(servletConnection.getOutputStream());
Msg outobj = new Msg(Msg.GET_STG);
outputToServlet.writeObject(outobj);
outputToServlet.flush();
outputToServlet.close();
ObjectInputStream inputFromServlet = new ObjectInputStream(servletConnection.getInputStream());
vStg = (Vector) inputFromServlet.readObject();
inputFromServlet.close();
}
catch(Exception g) {
g.printStackTrace();
}
return (vStg);
*********************************************************************************************
Servlet Code
*********************************************************************************************
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
ObjectOutputStream outputToApplet = null;
ObjectInputStream inputFromApplet = null;
try {
response.setContentType("application/x-java-serialized-object");
inputFromApplet = new ObjectInputStream(request.getInputStream());
System.out.println(inputFromApplet);
test = (Msg) inputFromApplet.readObject();
System.out.println(test);
if(test.getAuswahl() == 2) /*Msg.GET_STG*/{
outputToApplet = new ObjectOutputStream(response.getOutputStream());
outputToApplet.writeObject(mytestdat.vPlan);
outputToApplet.flush();
outputToApplet.close();
inputFromApplet.close();
}
}
catch (IOException e) {
e.printStackTrace();
}
catch (java.lang.ClassNotFoundException g) {
g.printStackTrace();
}
}