I'm starting to learn Ajax after playing around with JSP and Javascript, I felt the need for interaction without reloading the page.

I've searched everywhere for a simple java servlet/ajax example that I can play around with but just found a lot of asp and complex java examples.

Could someone please give me something as basic as typing a name in a text field and text being displayed beneath the text field after the word/letter has been typed. i.e. User must enter a name that is 3 or more letters else the text says "Error".

I'm currently using Netbeans, so if the example could work there, that wold be preferable!

Thanks a lot,

9 Years
Discussion Span
Last Post by AshtonHogan

Don't be silly... you know very well that it could be done with Ajax.

Sure, it COULD be done with AJAX but there is absolutely no reason to. The term/acronym AJAX describes making a request to the server then receiving and parsing XML. There is absolutely, positively no reason to do something so complex for validation.


I said that I'm starting to learn it... I just want to view how ajax works altogether in action to see how it allows requests/responses without reloading a page. I want to see how it runs a servlet without reloading the page. In the most basic form possible. Preferably on a Netbeans project. I've read a couple of tutorials and w3schools and so on, but I want to play around with it on Netbeans.


Thanks, but that doesn't really help. I've also found lots of casual ajax examples. They don't work on Netbeans though...


Try these two links, I havent tried them, but they seem to be pretty good


There are also loads of examples out there, you just have to search for them.

When i first started learning jsp, I came across a lot of examples that were incomplete, dont be discouraged though, just try solving them yourself, google helps a lot, a lot of the errors are newbie errors. but you will get the hang of it.


Thanks... I've already done the drop down list example and got it to work on Netbeans... It's a bit complicated though, I want something simple like the example I explained initially...



I found an easy Ajax example here:

It also contains a demo of the end product.

The only problem is that it requires a "time.asp" but does not contain much information on how to do that. I come from a JSP background and don't know anything at all about asp... Would it be possible to translate the code snippet they gave to JSP? Below is the asp code I need to translate to JSP:




Here is the servlet Version:

out.println(time.getHours() + ":" + time.getMinutes() + ":" + time.getSeconds());

Then just add the following code to your Javascript on the JSP:

function init(){

And call it here:

<body onload="init();">

This will run a function every 1000ms.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.