Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Java - URL connection accessing Java Scrpit Function

  1. #1
    Junior Member
    Join Date
    Aug 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Java - URL connection accessing Java Scrpit Function

    Hey Guys,

    I am trying to access a function at the following website - Listed Companies - all ASX, NZX, NSX and BSE
    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) -
    URL servAddress = new URL("http://www.delisted.com.au?javascript:__doPostBack('btnShowAll','')");
    URLConnection add = servAddress.openConnection();
     
    URLConnection add = servAddress.openConnection();
    BufferedReader in = new BufferedReader( new InputStreamReader(add.getInputStream()));
     
    while ((companyData = in.readLine()) != null)
    {
    System.out.println("HTML: "+companyData);
    }

    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 YouTube - ‪JavaScript hack‬‎. But so far that has not worked either.

    Ive tried various URL links such as -
    URL servAddress = new URL("http://www.delisted.com.au?javascript:__doPostBack('btnShowAll','')");
     
    URL servAddress = new URL("http://www.delisted.com.au#javascript:__doPostBack('btnShowAll','')");
     
    URL servAddress = new URL("http://www.delisted.com.au/javascript:__doPostBack('btnShowAll','')");
     
    URL servAddress = new URL("http://www.delisted.com.au/javasc#ipt:__doPostBack('btnShowAll','')");
     
    URL servAddress = new URL("http://www.delisted.com.au?javascript:__doPostBack('btnShowAll','0')");
    etc etc

    Thanks for any help in advance.
    Last edited by helloworld922; August 7th, 2010 at 10:58 AM.


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Java - URL connection accessing Java Scrpit Function

    Please surround your code with highlight tags. If you don't know how to, see my signature block.

    Have you tried this on a simpler webpage/javascript program? Try to get it working on a smaller sample then modify that code to work with the specific webpage/javascript method you are trying to call.

    Incidentally, you can just run javascript from your program using the Java scripting engine. See: Scripting for the Java Platform.

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Java - URL connection accessing Java Scrpit Function

    Cross posted at Java - URL connection accessing Java Scrpit Function - CodeGuru Forums

    Java Programming - Java - URL connection accessing Java Scrpit Function
    Last edited by Norm; August 7th, 2010 at 04:55 PM.

Similar Threads

  1. Need Help on the Interface Function
    By yel_hiei in forum Object Oriented Programming
    Replies: 12
    Last Post: July 29th, 2010, 07:27 AM
  2. [URGENT] - Problem accessing web sites with Java!
    By jguilhermemv in forum Java Networking
    Replies: 0
    Last Post: March 5th, 2010, 04:43 PM
  3. [SOLVED] Web portal accessing files on the user's system via the Java I/O stream?
    By rendy.dev in forum Web Frameworks
    Replies: 2
    Last Post: January 18th, 2010, 08:46 PM
  4. Substring function
    By bristol580 in forum Java SE APIs
    Replies: 2
    Last Post: November 12th, 2009, 11:29 AM
  5. Function of difference between two numbers
    By uplink600 in forum Java Theory & Questions
    Replies: 2
    Last Post: May 13th, 2009, 05:57 AM