Using AJAX with servlets is an excellent option for a J2EE developer. By using AJAX at client-side and a servlet at server-side, you can provide your users with a highly responsive and interactive web experience. This tutorial explains how.
Non-obtrusiveness, responsiveness and high interactivity are the areas where desktop applications still have an edge over web applications. The intelligent use of JavaScript can create highly interactive web sites. However, responsiveness and non-obtrusiveness would still be a distant dream.
The responsiveness can be achieved by careful implementation at server-side by using technology such as J2EE that uses threading mechanism to service requests. But, to achieve non-obtrusiveness, a component is required that can provide asynchronous means of communication so that complete re-rendering of a page during the response phase can be bypassed.
That is where AJAX comes into picture. AJAX provides asynchronous communication service through JavaScript and XML. Thus a good combination can be formed by using AJAX at client-side and a servlet at server-side, providing a non-obtrusive, responsive and highly interactive web experience.
In this discussion, I will focus on utilizing such a winning combination. The first sections will detail the steps required for setting up an application for utilizing AJAX along with a servlet. In the last section I will develop a registration module that will use AJAX to check the availability of the username. That is what’s in store for this discussion.