step1: Develop a Register form with Jquery
step2: Develop a Servlet Program ActionServlet.java
Step3: success form name s.jsp
Result :
Ater Click Button..Dispaly the Result
<script
src="jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#regbutton").click(function(event){
var user=$("#uname").val();
var address=$("#address").val();
$.get('ActionServlet',{user:user,address:address},function(responseText){
$("#regresult").text(responseText);
});
});
});
</script>
<div
id="register">
<h2>Register Form</h2>
<form id="reg">
<table border="2">
<tr>
<td>UserName:</td>
<td><input type="text"
name="uname" id="uname"></td>
</tr>
<tr>
<td>Address:</td>
<td><input type="text" name="address"
id="address"></td>
</tr>
<tr>
<td colspan="2"><input
type="button" value="Register"
id="regbutton"/></td>
</tr>
</table>
<div
id="regresult"></div>
</form>
</div>
step2: Develop a Servlet Program ActionServlet.java
/*
* To change this template, choose Tools |
Templates
* and open the template in the editor.
*/
package com.controller;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import
javax.servlet.http.HttpServletRequest;
import
javax.servlet.http.HttpServletResponse;
/**
*
* @author Naveen
*/
public class ActionServlet extends
HttpServlet {
public void service(HttpServletRequest request, HttpServletResponse
response)
throws ServletException,
IOException {
try {
String
user=request.getParameter("user");
request.setAttribute("u",user);
request.setAttribute("a",request.getParameter("address"));
request.getRequestDispatcher("s.jsp").forward(request,
response);
}catch(Exception e){
}
}
}
Step3: success form name s.jsp
Hi
User Name:<%=request.getAttribute("u")%>
Password:<%=request.getAttribute("a")%>
Registartion
success
Result :
Ater Click Button..Dispaly the Result
0 comments:
Post a Comment