If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Java - URL connection accessing Java Scrpit Function

Hey Guys,

I am trying to access a function at the following website - http://www.delisted.com.au/listed.aspx
There is a button there (only one) that will enable me to view all the data i need, however i am having a lot of trouble calling that java script function from my java program.
From What i can tell the function is called - javascript:__doPostBack('btnShowAll','')

Here is what i have tried to do (trust me Ive tried lots of variations) -
/////////////////////////////////////////////////

From what i know about javascript (not much) once i have the connection open (as i would in a standard internet browser) i should be able to remove the url and call the function directly - see http://www.youtube.com/watch?v=bNBWvaLKSYw. But so far that has not worked either.

Re: Java - URL connection accessing Java Scrpit Function

What do you expect the server to return with those URLs?
I wouldn't expect the server to act like a browser: read the html, scan for a JS function in the html, execute the function and return the results.

Re: Java - URL connection accessing Java Scrpit Function

I am trying to get the results of the button (java script). That is the browser has the same url (once the button has been selected) however 2500 companies are listed instead of a simple page with a button on it.
I was trying to find a library that would allow my program to act like a browser (in the sence i could call java script functions - act like a user clicking the button) or in the examples i just posted accessing the java script function directly via a direct URL value.

Re: Java - URL connection accessing Java Scrpit Function

The full data from that page ( a list of 2500 companies listed with the ASX with their current trading status). I'm making a stock market competition program and this is the only source i can find for this data, just that button is not allowing me to view it via my java app.

Re: Java - URL connection accessing Java Scrpit Function

What HTTP GET/POST request is generated by the button press?
Can you capture the URL and GET/POST request sent by the browser when the button is pressed and use that in your program?
Does the button press generate an https or http request?
Can you use a proxy server that will capture the request sent from the browser using that proxy server when the button is pressed?

Re: Java - URL connection accessing Java Scrpit Function

I have no idea, if you haven't already, please have a look at the site - http://www.delisted.com.au/listed.aspx - its a very simple page with a single button, it wont take you more than a few minutes to see whats happening in source code view.
Also why does it matter if I've "Cross Posted"? Its just asking more people the same question.

Re: Java - URL connection accessing Java Scrpit Function

I have looked at that page and seen its HTML and javascript. The responses to your post on the sun/oracle site describes what you need to do.

why does it matter if I've "Cross Posted"?

Because: why should I waste my time researching and posting an answer that has already been posted on another forum???
You should post links to the other sites so we can see the progress on this topic and not waste our time.

Re: Java - URL connection accessing Java Scrpit Function

The Post from the oracle website shows me how i can get that running with other applications, and shows me how to run java scripts on my own local host, however if you research into each of those posts a bit further you will find they still don't solve my issue of executing a java script functions results from my java app from an external source.

As for the cross posting thing, next time ill be sure to update, sorry about that.

Re: Java - URL connection accessing Java Scrpit Function

Hey,

Just for reference i thought i would post my solution - very little out there for this kind of thing (from what i saw).

Anyway, i wanted to access a java script function within a HTML page and couldn't seem to using standard URL connections, so I found the htmlunit package - http://htmlunit.sourceforge.net/ - which allows your java application act like a web browser (that is click-able items, execute java script functions or full applications etc). Before you use it, just to let you know there is not alot of examples out there for this library yet but i found one good example that helped me - http://selenium.googlecode.com/svn-h...nitDriver.java.

I could not get the function executeJavaScriptFunctionIfPossible working so i found a method which allows you to "click" on an object, essentially making your app act like a user.

And here is the code i used to extract the java script results to a string -

* The Perfect Platform for Game Developers: Android
Developing rich, high performance Android games from the ground up is a daunting task. Intel has provided Android developers with a number of tools that can be leveraged by Android game developers.

* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.