Results 1 to 4 of 4
  1. #1
    dhazwa is offline Member
    Join Date
    Jul 2011
    Posts
    15
    Rep Power
    0

    Default Input text into online html form using java

    Hello,

    I need some help figuring out how to create a program, using java, that will open up a web browser, go to a specific url, and on that page fill out an html form and then click submit. If anyone is wondering why I want to do this in java, it is because I took a basic intro to java class in college and it is the only language I know how to write a little bit. I tried looking up how to do this on Google, and found some forums that addressed this question, but when I tried it, it did not work. Any help or pointers would be greatly appreciated. Thanks!

    The URL for the page with the form is Quick-Move Transport: Request Movers - Pick-Up/Delivery.

    This is what I have for my code so far; all the program does is open up internet explorer and go to the url stated:



    import org.w3c.dom.html.HTMLFormElement;

    public class OpenClose {

    /**
    * @param args
    */
    public static void main(String[] args) {
    try {
    Process p = Runtime.getRuntime().exec("C:\\Program Files\\Internet Explorer\\iexplore.exe \"http://www.quickmovetransport.com/deliverycalculatormobile\"");
    //Thread.sleep(120000);
    //p.destroy();
    } catch (Exception e) {}

    }

    }

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    that will open up a web browser, go to a specific url, and on that page fill out an html form and then click submit
    Why have a browser? You can read the HTML, get the <FORM tag and do the action all from within a java program.
    An exception would be if the html page uses javascript to create the <FORM.

    Otherwise the choice would be to use the Robot class. It can position the mouse, enter text and press a mouse button.

  3. #3
    dhazwa is offline Member
    Join Date
    Jul 2011
    Posts
    15
    Rep Power
    0

    Default

    Thanks Norm!

    I will definitely look into the Robot class. This project is actually just kind of a practice for what I am really working on, which I am pretty sure will need to be done in a browser. Will the Robot class work in a browser, and if you don't mind sharing, how do I get java to get the form tag?
    Thanks again for the response Norm, I really appreciate it!

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    Will the Robot class work in a browser
    Not unless the Applet it is executing in is signed.
    I thought you were describing an app that started a process that executed a browser and then you wanted to "type" data into the browser's displayed HTML page.

    how do I get java to get the form tag?
    Have the java program send an HTTP GET to a server for the HTML page and then parse that page for the <FORM tag.
    There are a lot of sample programs here that do that. Search for URLConnection for example.

Similar Threads

  1. Replies: 6
    Last Post: 04-06-2011, 12:39 PM
  2. POST information to html form via java?
    By alacn in forum New To Java
    Replies: 7
    Last Post: 08-20-2010, 06:01 AM
  3. Replies: 10
    Last Post: 08-12-2009, 04:02 PM
  4. Help in reading values from html form in java
    By ichkoguy in forum Advanced Java
    Replies: 7
    Last Post: 03-16-2009, 07:45 AM
  5. convert html to text using java
    By praveen@asia-mail.com in forum New To Java
    Replies: 1
    Last Post: 11-14-2007, 02:08 PM

Tags for this Thread

Posting Permissions

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