Accessing Java API

Discussion in 'Programming' started by wrekoniz3, Oct 23, 2013.

  1. #1
    I am looking for the easiest way to access a Java API on a webpage. So the webpage can display information from the Java API.

    Any ideas? Greatly appreciated.
     
    wrekoniz3, Oct 23, 2013 IP
  2. sarahk

    sarahk iTamer Staff

    Messages:
    28,818
    Likes Received:
    4,536
    Best Answers:
    123
    Trophy Points:
    665
    #2
    You will need to make an ajax call back to the server to load a java script
    Java is run on the server
    Javascript is run on the webpage
     
    sarahk, Oct 23, 2013 IP
  3. wrekoniz3

    wrekoniz3 Well-Known Member

    Messages:
    2,232
    Likes Received:
    100
    Best Answers:
    0
    Trophy Points:
    190
    #3
    ok, so how do you interface with the java from the javascript? You have an example or something? I have put a lot of research into this. Hours, have not been able to get this done.
     
    wrekoniz3, Oct 23, 2013 IP
  4. sarahk

    sarahk iTamer Staff

    Messages:
    28,818
    Likes Received:
    4,536
    Best Answers:
    123
    Trophy Points:
    665
    #4
    You build a script using java and then call it from the ajax script the same way you would a .php or .asp page.

    Do you have your script in Java written? tested?
     
    sarahk, Oct 23, 2013 IP
  5. wrekoniz3

    wrekoniz3 Well-Known Member

    Messages:
    2,232
    Likes Received:
    100
    Best Answers:
    0
    Trophy Points:
    190
    #5
    wrekoniz3, Oct 24, 2013 IP
  6. sarahk

    sarahk iTamer Staff

    Messages:
    28,818
    Likes Received:
    4,536
    Best Answers:
    123
    Trophy Points:
    665
    #6
    That article was overly complicated since people rarely use raw ajax and instead use a library like prototype or jquery.

    The guts of it though was that it called a java script - in this case "helloworld.java"
    and that is what you are trying to do.

    Have you written your java script yet? or is your real problem that you don't have access to the server running java?
     
    sarahk, Oct 24, 2013 IP
  7. wrekoniz3

    wrekoniz3 Well-Known Member

    Messages:
    2,232
    Likes Received:
    100
    Best Answers:
    0
    Trophy Points:
    190
    #7
    The java part is partially written, like I can compile it down to a class file as is to test right now. I just don't to put hours into dev right now with out knowing this will work for sure. I can test it right now - I am just figuring out how to set up the servlet on tomcat, then figuring out how to make requests to the servlet.

    What do you mean by "is your real problem that you don't have access to the server running java?" - If this means what I think it does...my problem is I don't actually know how to make the connection between the ajax/jquery and java servlet.
     
    wrekoniz3, Oct 26, 2013 IP
  8. sarahk

    sarahk iTamer Staff

    Messages:
    28,818
    Likes Received:
    4,536
    Best Answers:
    123
    Trophy Points:
    665
    #8
    Lets start over. Can you explain what you are trying to do.

    Back in the old days the flow was this
    • the browser requests a web page
    • the server finds the file which generates the page. If it's .html then it just returns that file, if it's .php, .asp etc then it executes the script which in turn may call more scripts. They all, however, return plain text which is read by the browser.
    • The browser receives the plain text and reads it and decides if that text is a web page, an xml feed, an image, a flash file etc and shows it to the user
    Nowadays with ajax we can add a 4th step
    • the user interacts with a webpage and a) requests a new page; or b) sends an ajax command back to the server
    From your initial question I thought you were at the 4th step where the page had been shown to the user and you needed a small command to be back to the ajax server and return with some extra html etc.

    I'm now wondering if you are really back at step 1 trying to get a page loaded.
     
    sarahk, Oct 27, 2013 IP