This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java and JavaScript functions

 
Ian Morris
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an HTML form (within a jsp) with an input text box, is there a way I can do the following:
1. User enters some text into a text input box
2. User presses a button next to the text box
3. The button invokes a javaScript fuction
4. The javaScript invokes a java servlet which does an ldap query using the text from the original HTML text box.
5. The ldap query returns some data to the javaScript function
6. The javaScript function updates the html page.
I do not know how to do steps 4 and 5, has anybody done something similar, or know how to do this?
Help greatly appreciated.
Ian.
 
Shama Khan
Ranch Hand
Posts: 185
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ian Morris:
I have an HTML form (within a jsp) with an input text box, is there a way I can do the following:
1. User enters some text into a text input box
2. User presses a button next to the text box
3. The button invokes a javaScript fuction
4. The javaScript invokes a java servlet which does an ldap query using the text from the original HTML text box.
5. The ldap query returns some data to the javaScript function
6. The javaScript function updates the html page.
I do not know how to do steps 4 and 5, has anybody done something similar, or know how to do this?
Help greatly appreciated.
Ian.

Well, I've used java code in calling methods of beans within the javascript but not called a servlet.
You could also call the servlet right from the button. I am pretty sure that a servlet can only be called with a get/post from a form/action. Apologies for vagueness.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17621
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"I am pretty sure that a servlet can only be called with a get/post from a form/action".
Close enough. HTML isn't that dynamic anyway. A Java Applet can open a URLConnection and do a GET or POST, but it can only update the part of the web page contained within the applet's defined box area. JavaScript could only do a submit(), which means that the whole page would have to be recreated.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic