Thursday, October 15, 2009

Simple Ajax Example of UserName and Password Validations

Below set of codes are the examples of Ajax which takes the username and password from a XML file stored in the server directory.

Below example has a parent window, where an Edit Label is there. On click on Edit Label, it will go to a child window and will have provision to enter username and password. The username and password, entered, will be checked with those of parent window, which has been populated from a XML file using Ajax.

Before going into the code, let’s have some basics of Ajax:

AJAX is Asynchronous JavaScript and XML and based on JavaScript and HTTP requests. With AJAX, a JavaScript can communicate directly with the server, with the XMLHttpRequest object. With this object, a JavaScript can trade data with a web server, without reloading the page.

AJAX uses asynchronous data transfer (HTTP requests) between the browser and the web server, allowing web pages to request small bits of information from the server instead of whole pages.

Source Codes:

This example consists of five jsps and one Credentials.xml [in the server directory]

testAjax.jsp, time.jsp, EnterCredentials.jsp, UserName.jsp, Password.jsp

If the username and password matches with the one which are stored in the server, it will automatically check the checkbox in the parent window.

testAjax.jsp



time.jsp



EnterCredentials.jsp




UserName.jsp



Password.jsp




Credentials.xml in the server directory






No comments:

Total Pageviews