Problem writing object from applet to server in Firefox (Linux)

  • Follow


Hi,I'm trying to write an Java applet that will send an object, via a TCPsocket, to a Java application running on the same machine.  It worksin Opera and Mozilla, but it doesn't work in Firefox - the Javaapplication appears to receive an incoming connection, but neveractually reads the object.Any ideas how to resolve this problem?Code://///////////////////// APPLET ////////////////////////////import java.applet.Applet;import java.io.BufferedOutputStream;import java.io.ObjectOutputStream;import java.net.Socket;public class AppletClient extends Applet {    private Socket socket;    private ObjectOutputStream oos;    public void start() {        System.out.println("Hello there!");        try {            String host = getCodeBase().getHost();            socket = new Socket("127.0.0.1", 55000);            oos = new ObjectOutputStream(newBufferedOutputStream(socket.getOutputStream()));            TestObject t = new TestObject("Hello!");            oos.writeObject(t);            oos.flush();            oos.close();        }        catch (Exception e) {            e.printStackTrace();        }    }}/////////////////////// APPLICATION ////////////////////////////import java.io.BufferedInputStream;import java.io.ObjectInputStream;import java.net.ServerSocket;import java.net.Socket;public class Server {    private static ServerSocket serv;    private static Socket sock;    private Server() {    }    public static void main(String[] args) {        try {            serv = new ServerSocket(55000);            System.out.println("Server listening on port " +serv.getLocalPort());            sock = serv.accept();            System.out.println("Received connection: " +sock.getInetAddress()                                           + ":" + sock.getPort());            ObjectInputStream ois = new ObjectInputStream(newBufferedInputStream(sock.getInputStream()));            System.out.println("Opened input stream.  Attemping toread object.");            TestObject t = (TestObject) ois.readObject();            ois.close();            t.print();        }        catch (Exception e) {            e.printStackTrace();        }    }}/////////////////////// OBJECT TO SEND ////////////////////////////import java.io.Serializable;public class TestObject implements Serializable {    private String s;    public TestObject(String s) {        this.s = s;    }    public void print() {        System.out.println(s);    }}Thanks,Duncan Jones
0
Reply dmj29 (4) 4/4/2007 1:50:46 PM

Duncan Jones wrote:(applet)>...It works>in Opera and Mozilla, but it doesn't work in Firefox - the Java>application appears to receive an incoming connection, but never>actually reads the object.>>Any ideas how to resolve this problem?You might try removing browsers from the loop,(and will possibly get a more consistent result)by launching the applet using Web Start.<http://www.physci.org/jws/#jtest>HTH-- Andrew Thompsonhttp://www.athompson.info/andrew/Message posted via JavaKB.comhttp://www.javakb.com/Uwe/Forums.aspx/java-general/200704/1
0
Reply Andrew 4/4/2007 2:26:21 PM


On 4 Apr, 15:26, "Andrew T." <u32984@uwe> wrote:> Duncan Jones wrote:>> (applet)>> >...It works> >in Opera and Mozilla, but it doesn't work in Firefox - the Java> >application appears to receive an incoming connection, but never> >actually reads the object.>> >Any ideas how to resolve this problem?>> You might try removing browsers from the loop,> (and will possibly get a more consistent result)> by launching the applet using Web Start.> <http://www.physci.org/jws/#jtest>>> HTH>> --> Andrew Thompsonhttp://www.athompson.info/andrew/>> Message posted via JavaKB.comhttp://www.javakb.com/Uwe/Forums.aspx/java-general/200704/1Sadly, this HAS to occur within a browser, as it's part of a largerautomated program that needs to determine when a web page has loaded...
0
Reply Duncan 4/4/2007 2:36:35 PM

On 4 Apr, 15:36, "Duncan Jones" <d...@cam.ac.uk> wrote:> On 4 Apr, 15:26, "Andrew T." <u32984@uwe> wrote:>>>> > Duncan Jones wrote:>> > (applet)>> > >...It works> > >in Opera and Mozilla, but it doesn't work in Firefox - the Java> > >application appears to receive an incoming connection, but never> > >actually reads the object.>> > >Any ideas how to resolve this problem?>> > You might try removing browsers from the loop,> > (and will possibly get a more consistent result)> > by launching the applet using Web Start.> > <http://www.physci.org/jws/#jtest>>> > HTH>> > --> > Andrew Thompsonhttp://www.athompson.info/andrew/>> > Message posted via JavaKB.comhttp://www.javakb.com/Uwe/Forums.aspx/java-general/200704/1>> Sadly, this HAS to occur within a browser, as it's part of a larger> automated program that needs to determine when a web page has loaded...For whatever reason, this problem seems to have fixed itself.  Whichnaturally worries me a bit, but I'll just cross my fingers and see...
0
Reply Duncan 4/4/2007 9:46:57 PM

3 Replies
104 Views

(page loaded in 0.092 seconds)


Reply: