1.
1 <%@ page language="java" contentType="text/html; charset=UTF-8" 2 pageEncoding="UTF-8"%> 3 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 4 <html> 5 <head> 6 <meta http-equiv="Content-Type" content="text/html;charset=utf-8"> 7 <title>显示欢迎信息</title> 8 <link rel="stylesheet" href="common.css" type="text/css" /> 9 <script src="jquery-1.5.2.js" type="text/javascript"></script> 10 <script type="text/javascript"> 11 $(document).ready( function() { 12 $('#submit').click(function(){ 13 var name = $('.uname').val(); 14 var data = 'uname='+name; 15 alert(data); 16 $.ajax( 17 { 18 type:"POST", 19 url:"welcom.jsp", 20 data:data, 21 success: function(html) { 22 $('#message').html(html); 23 } 24 } 25 ); 26 return false; 27 }); 28 }); 29 </script> 30 </head> 31 <body> 32 <form> 33 <label>Enter your name</label> 34 <input type="text" name="uname" class="uname" /><br /> 35 <input type="submit" id="submit" value="Submit" /> 36 </form> 37 <div id="message"></div> 38 </body> 39 </html>
2.
1 <%@ page language="java" contentType="text/html; charset=UTF-8" 2 pageEncoding="UTF-8"%> 3 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 4 <html> 5 <head> 6 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 7 <title>Insert title here</title> 8 </head> 9 <body> 10 欢迎光临.....<%=request.getParameter("uname")%> 11 </body> 12 </html>