i am building a web chat application for mobiles. Registration form for new users currently includes username , password , re-enter password and a submit button to send all to a form bean. i am having problem to create a link or a button to send the input of 'username' textfield to some servlet to check user availability from database. So that the user can check before registering (clicking Submit buttom). the code is mentioned below. A sample....
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@ taglib uri="web-inf/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@page import="java.sql.*"%>
<%@page import="java.io.*"%>
<%@page import="java.net.*"%>
<%@page import="java.util.*"%>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<body>
<html:errors />
<font color="DeepSkyBlue">Please Enter details</font><br>
<html:form action="/newuserdata">
<img src="small-logo.JPG" width="38" height="51" alt="u" /> <br>
<a href="check.jsp"/>check username availability </a>
<table>
<tr><td>UserName:</td></tr>
<tr><td><html:text property="name"></html:text></td></tr>
<%
String varname="ajit";
// String g = session.setAttribute("varname", request.getParameter("name"));
%>
<tr><td><input type="button" onclick="location='check?name=<%=varname%>'" value="Check" /></td></tr>
<tr><td><a href="check?name=""/>check it </a></td></tr>
<!-- <form name="newform" action="check?name=<" method="post">
<input type="hidden" name="userID" value="27566">
<input type="submit" value="check">
</form> -->
<tr><td>Password:</td></tr>
<tr><td><html:password property="pass"></html:password></td></tr>
<tr><td>Re-enter Password:</td><td>
<tr><td><html:password property="pass1"></html:password></td></tr>
<tr><td><input type="submit" value="Submit" name="submit" /></td></tr>
</table>
</html:form>
</body>
</html>
I want to check user availability on the same page or when i click check ONLY THE USERNAME TEXTFIELD should be submitted to a servlet.
CAN THE TEXT ENTERED IN A TEXTFIELD BE SAVED IN A STRING... SO THAT I CAN SEND AS SERVRET?NAME= <%=STRING%> ......
can 2 submit buttons with different names and certain process should be done accordingly to the button which is clicked. Please let me know the correct way to solve this...