This week's book giveaways are in the Scala and Android forums.
We're giving away four copies each of Machine Learning Systems: Designs that scale and Xamarin in Action: Creating native cross-platform mobile apps and have the authors on-line!
See this thread and this one for details.
Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how a servlet can return value to a html?  RSS feed

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey all

please help me in following

I want to have an HTML page called SignUp.html and a servlet called CheckValidation.java


now there is a textBox in HTML called UserName.

CheckValidation just check whether the username the user entered is available or not. it have the connection with database and if the username is already present in the database then it must return that the usename is not available.

i want that UserName text onBlur event call that servlet and check the availability of username and write it in the lable next to username.

i can put tha servlet in onBlur event of the username but the problem is that how the servlet will retrun the value to that html??

Can a Servlet return any value to an HTML page? if yes then how can the html page can get it. ? if no then please suggest me any other way to do this.

thanhx.
 
Author and ninkuma
Marshal
Posts: 66677
167
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can make an Ajax request to the servlet.
 
Sachin Kadian
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i dont know about azax.. how can i use this please help..
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66677
167
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ajax, not azax.

The servlet can return any text value as the response.

If you don't know anything about Ajax, what did you mean by:

i can put tha servlet in onBlur event of the username

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to make ajax call using the XMLHTTPObject and then get the response.
First create a xmlHTTPObject. set the input parameter and make the request to the servlet.

check this.

http://www.degraeve.com/reference/simple-ajax-example.php
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66677
167
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

harish Gunda wrote:You need to make ajax call using the XMLHTTPObject


It's XMLHttpRequest, not XMKHTTPObject.
 
Fire me boy! Cool, soothing, shameless self promotion:
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!