Results 1 to 2 of 2
  1. #1
    joea9 is offline Member
    Join Date
    May 2011
    Posts
    1
    Rep Power
    0

    Default Retrieving data from an embedded web page

    Hey all, I've just started learning Java and I've got an idea for a first project that would be functional for my work. I want to display a web page within a Java applet, and then retrieve data from the current active page.

    I've managed to get a web page to display using SWT (found some demo code that does this). But I've got no idea how to retrieve data from this page.

    I have also found some code that will retrieve data from A webpage and return it within a variable, BUT, The page I'm accessing is an existing application that requires PKI login and various other actions, so the page I want to grab data from is a long URL that I wouldn't be able to access in this way.

    This is why I need to embed the page and grab data from the current active page. Hope this makes sense, has anyone got any ideas how I can do this?



    In case it helps this is the code I've got for embedding the page -

    import org.eclipse.swt.*;
    import org.eclipse.swt.widgets.*;
    import org.eclipse.swt.browser.*;
    import org.eclipse.swt.layout.*;

    public class embedtest {

    public static void main(String [] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());
    shell.setText("WebKit");
    final Browser browser;
    try {
    browser = new Browser(shell, SWT.NONE);
    } catch (SWTError e) {
    System.out.println("Could not instantiate Browser: " + e.getMessage());
    display.dispose();
    return;
    }
    shell.open();
    browser.setUrl("http://webkit.org");
    while (!shell.isDisposed()) {
    if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
    }
    }
    Last edited by joea9; 05-01-2011 at 10:20 AM.

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    7

    Default

    See Reading Directly from a URL (The Java™ Tutorials > Custom Networking > Working with URLs) , which will allow you to read the content of the URL, set any header information, and you can use the read data to pass to the Browser using setText method of Browser (rather than setURL)

Similar Threads

  1. Retrieving data from database every 10 secs.
    By vnsuresh.abi in forum JavaServer Pages (JSP) and JSTL
    Replies: 4
    Last Post: 03-31-2011, 11:14 AM
  2. retrieving data from token
    By bozovilla in forum Advanced Java
    Replies: 4
    Last Post: 09-30-2010, 08:49 AM
  3. Store data is not retrieving
    By JavaJunkie in forum CLDC and MIDP
    Replies: 2
    Last Post: 05-30-2009, 08:08 AM
  4. error while retrieving data from data base
    By kirtesh4u in forum New To Java
    Replies: 5
    Last Post: 11-15-2008, 04:10 PM
  5. Retrieving data from the DB
    By yuchuang in forum JDBC
    Replies: 2
    Last Post: 11-27-2007, 08:59 AM

Posting Permissions

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