www.webdeveloper.com
Results 1 to 3 of 3

Thread: java program to open a web page in browser and post data into the same opened page

Hybrid View

  1. #1
    Join Date
    Mar 2014
    Posts
    1

    java program to open a web page in browser and post data into the same opened page

    i m stuck into a situation. The problem is that i want to write a java program/function which opens a web page in a default browser and post some data into that same opened web page.


    Please could anyone guide me to do this. I dont have a clue in this.

    Your help is much appreciated. Thanks in advance

  2. #2
    Join Date
    Mar 2014
    Posts
    1
    This may be useful..


    import java.awt.Desktop;
    import java.net.URI;

    public class OpenBrowser {

    public static void main(String[] args) throws Exception {
    String url = "http://stackoverflow.com";

    if (Desktop.isDesktopSupported()) {
    // Windows
    Desktop.getDesktop().browse(new URI(url));
    } else {
    // Ubuntu
    Runtime runtime = Runtime.getRuntime();
    runtime.exec("/usr/bin/firefox -new-window " + url);
    }
    }
    }

  3. #3
    Join Date
    Dec 2012
    Posts
    54
    I know I'm super late but maybe if someone looks in the future they'll at least find an answer.

    You can use a PHP script to receive the data and append it to your browser address.

    I wrote a php script a while back to dump data from a cell phone game I was having users test. Basically the PHP would receive two variables which were the level they were on and the time they took to complete.
    The webaddress looked something like
    http://www.thedomainname.com/postscores.php?level=[level number]&time=[completion time]

    The Java Program would insert the value of the two variables in the program to the URL address and then close the connection. The php script would then receive the two variables and store them in a database. Then finally you just build a way to view it which for me was a 3rd PHP page that would query the database and dynamically display the information.

    This had all phones that had the game send data in real time so I could monitor scoring and get an idea of average level completion times.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles