Results 1 to 3 of 3

Thread: Applet fails to start server from webbrowser

Hybrid View

  1. #1
    Join Date
    Oct 2007
    Location
    Melbourne, Australia
    Beans
    101
    Distro
    Ubuntu 11.10 Oneiric Ocelot

    Applet fails to start server from webbrowser

    Hi all

    My applet connects to a local server. If not found, it loads the server and retries the connection.

    "java class" runs fine, but running in a browser using html fails to load server. html works fine if server is already running.

    I am using the Runtime class to start the server. Dont know if there is a recommended way of doing this


    My client code and html is attached

    Snippet to start server

    Code:
    SocketAddress sa;
            while(starting){
    try{            link= new Socket("localhost",PORT);
                    ta.append("Server connect on port "+PORT+"\n");
                    starting=false;
    }catch (Exception e){
                    ta.append("Server not found\n");
                    ta.append("Error: "+e+"\n");
                    cnt++; if(cnt==3)return;
    try{            ta.append("Starting Server\n");
                    Runtime rt=Runtime.getRuntime();
                    Process proc=rt.exec("java Misam");
    try{            Thread.sleep(1000);
    }catch (InterruptedException ie){ta.append(ie.getMessage()+"\n");}
    }catch (Throwable t){ ta.append("Server started\n");}
                    }
    Last edited by bcz; February 16th, 2011 at 01:39 AM. Reason: Use code tags, attach files which got lost

  2. #2
    Join Date
    Oct 2007
    Location
    Melbourne, Australia
    Beans
    101
    Distro
    Ubuntu 11.10 Oneiric Ocelot

    Re: Applet fails to start server from webbrowser

    Files which should have been attached
    Attached Files Attached Files

  3. #3
    Join Date
    Nov 2010
    Location
    Down the rabbit hole
    Beans
    435
    Distro
    Ubuntu Development Release

    Re: Applet fails to start server from webbrowser

    "java class" runs fine, but running in a browser using html fails to load server. html works fine if server is already running.
    It might be an applet security limitation. To get around any applet security limitation you have to sign the applet, how to do that - google.
    Remember, when you do stuff from a typical Java Swing app (inside JFrame) you have one type of security (basically none), when in applet another (no file access, and who knows what else).
    Check the java console or make your applet/app display a dialog displaying the error so that you know what type of error happened in your applet so you can make progress.
    Your ads here, just 9.99$/week !!

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •