1<body>2<center>3"myimg"Src="fruit3.jpg"></img>4<form method="Post"action="Servlet/first">5<table>6<tr>7<td> User name:</td>8<td><input type="text"Name="username"></td>9</tr>Ten One<tr> A<td> Password:</td> -<td><input type="Password"Name="Password"></td> -</tr> the - -<tr> -<td><input type="Submit"Value="Submit"Name="Submit"></td> +</tr> -</table> +</form> A</center> at</body> -<body> -<center> - -<jsp:usebean id="Userbean" class="entity.users"Scope="Session"></jsp:useBean> - in<form method="Post"> -<table> to<tr> +<td> User name:</td> -<td><jsp:getproperty name="Userbean"property="username"></jsp:getProperty></td> the</tr> * $<tr>Panax Notoginseng<td> Password:</td> -<td><jsp:getproperty name="Userbean"property="Password"></jsp:getProperty></td> the</tr> + A<tr> the<td></td> +</tr> -</table> $</form> $</center> -</body> - protected voidDoPost (httpservletrequest request, httpservletresponse response) throws Servletexception, IOException { theRequest.setcharacterencoding ("Utf-8"); -Response.setcontenttype ("TEXT/HTML;CHARSET=GBK");WuyiPrintWriter out=Response.getwriter (); theUsers u =Newusers (); -String name=""; WuString password=""; - AboutName=request.getparameter ("username"); $Password=request.getparameter ("Password"); - u.setusername (name); - U.setpassword (password); -Request.getsession (). SetAttribute ("Userbean", u);//session can also add Objects A //Request.getrequestdispatcher (".. /success.jsp "). Forward (request, response); + the - Try{ $RequestDispatcher Rdispatcher=request.getrequestdispatcher (".. /success.jsp"); the Rdispatcher.forward (request, response); the out. println ("Finally, it's not a damn exception."); the the } - Catch(Exception ex) { in the out. println ("An exception occurred! "); the ex.printstacktrace (); About the } the the + - the Bayi the}
Javaweb trial Sledgehammer (ii)