Beitrag 75 von 610 (12%) | Antworten Beitrag schreiben | Anfang zurück weiter Ende |
|
Hallo
solange ich Objekte immer nur in eine Richtung übertrage (Applet -> Servlet oder Servlet -> Applet), funktioniert die Kommunikation. Wenn aber das Applet Objekte an das Servlet schickt und das Servlet daraufhin Objekte an das Applet zurück senden soll empfängt das Applet nichts. Es werden auch keine Exceptions ausgelöst.
Applet (Methode)
***********************************************
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();
ObjectInputStream inputFromServlet = new ObjectInputStream(servletConnection.getInputStream());
vStg = (Vector) inputFromServlet.readObject();
inputFromServlet.close();
outputToServlet.close();
}
catch(Exception g) {
g.printStackTrace();
}
return (vStg);
Servlet
***********************************************
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();
inputFromApplet.close();
if(test.getAuswahl() == 2) /*Msg.GET_STG*/ {
outputToApplet = new ObjectOutputStream(response.getOutputStream());
outputToApplet.writeObject(mytestdat.vPlan);
outputToApplet.flush();
outputToApplet.close();
}
}
catch (IOException e) {
e.printStackTrace();
}
catch (java.lang.ClassNotFoundException g) {
g.printStackTrace();
}
}