aspose file tools*
The moose likes Servlets and the fly likes Java and JavaScript functions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Java and JavaScript functions" Watch "Java and JavaScript functions" New topic
Author

Java and JavaScript functions

Ian Morris
Greenhorn

Joined: May 23, 2001
Posts: 7
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

Joined: Aug 14, 2000
Posts: 185
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.

Shama
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16250
    
  21

"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.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java and JavaScript functions