aspose file tools*
The moose likes Servlets and the fly likes how a servlet can return value to a html? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "how a servlet can return value to a html?" Watch "how a servlet can return value to a html?" New topic
Author

how a servlet can return value to a html?

Sachin Kadian
Ranch Hand

Joined: Jan 24, 2012
Posts: 33
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.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61413
    
  67

You can make an Ajax request to the servlet.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Sachin Kadian
Ranch Hand

Joined: Jan 24, 2012
Posts: 33
i dont know about azax.. how can i use this please help..
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61413
    
  67

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
harish Gunda
Greenhorn

Joined: Jan 31, 2012
Posts: 4
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

Joined: Jan 10, 2002
Posts: 61413
    
  67

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

It's XMLHttpRequest, not XMKHTTPObject.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how a servlet can return value to a html?