Results 1 to 2 of 2
- 05-01-2011, 10:16 AM #1
Member
- Join Date
- May 2011
- Posts
- 1
- Rep Power
- 0
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.
- 05-01-2011, 04:02 PM #2
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,619
- Rep Power
- 5
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
-
Retrieving data from database every 10 secs.
By vnsuresh.abi in forum JavaServer Pages (JSP) and JSTLReplies: 4Last Post: 03-31-2011, 11:14 AM -
retrieving data from token
By bozovilla in forum Advanced JavaReplies: 4Last Post: 09-30-2010, 08:49 AM -
Store data is not retrieving
By JavaJunkie in forum CLDC and MIDPReplies: 2Last Post: 05-30-2009, 08:08 AM -
error while retrieving data from data base
By kirtesh4u in forum New To JavaReplies: 5Last Post: 11-15-2008, 04:10 PM -
Retrieving data from the DB
By yuchuang in forum JDBCReplies: 2Last Post: 11-27-2007, 08:59 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks