Seite 1 von 1 [2 Beiträge im Thema] | Beitrag schreiben | Anfang zurück weiter Ende |
JavaForum - Meckerecke - Servlet sendet keine Objekte ans Applet
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();
}
}
beim Herrunterfahren vom Tomcat erhalte ich noch folgenden Exception, mit der ich aber nichts anfangen kann.
Stopping service Tomcat-Standalone
java.net.BindException: Cannot assign requested address: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:355)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:142)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:129)
at java.net.Socket.<init>(Socket.java:273)
at java.net.Socket.<init>(Socket.java:127)
at org.apache.jk.common.ChannelSocket.destroy(ChannelSocket.java:384)
at org.apache.jk.server.JkMain.stop(JkMain.java:311)
at org.apache.jk.server.JkCoyoteHandler.destroy(JkCoyoteHandler.java:181)
at org.apache.coyote.tomcat4.CoyoteConnector.stop(CoyoteConnector.java:1205)
at org.apache.catalina.core.StandardService.stop(StandardService.java:546)
at org.apache.catalina.core.StandardServer.stop(StandardServer.java:2225)
at org.apache.catalina.startup.Catalina.start(Catalina.java:543)
at org.apache.catalina.startup.Catalina.execute(Catalina.java:400)
at org.apache.catalina.startup.Catalina.process(Catalina.java:180)
at java.lang.reflect.Method.invoke(Native Method)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:203)