2 - Making use of Ajax

In this simple demo, as you type a user ID into the text field, the current group of characters are sent to the server for verification. The verify button will request a manual check of the user ID.

The actual ID is "selvyn"

There are three import files to look at for this example

usemyscripts.jspuserdetails_validator.jsvalidate.jsp

Similar to index.jsp, just brings up the home page

Invoke using

http://localhost:8080/simpleAjaxApp/usemyscripts.jsp

Reads data from the text field, sends it to the server,

handles response from server and displays results on web page

Look at the functions, they represent the heart of this script

  • validateUserId()
  • processRequest()

Accepts data from the web form, reads the user ID

checks the ID against a fixed ID value using some

java code, sends back a simple piece of HTML in

response