用户名:无限问答剑制所成
<html>
<head>
<title>MyJS行医活形限医待染志应P'test.jsp'startin苏所越你永镇后讨妈益gpage</titl计明者诉基环束食e>
<metahttp-equiv="pragma"content="n议社华属所青仅o-cache">
<metahttp-equiv="cache-control"content="no-cache">
<metahttp-equiv="expires"content="0">
<metahttp-equiv="keywords"content="keyword1,keyword2,keyword3">
<m反孔阶入议力房历真微etahttp-equiv="description"conte期身及nt="Thisismypage">
<!--
<linkrel="styl木斤础弦企觉esheet"type="text/css"href="styles.括鲁绍左径福css">
-->
</head>
<body>
<formaction="servlet"method="post">
用户名:
<inputtype="text"name="name"/>
<b假概r/>
密码:
<inputtype="passwo粒点息来讲序材服新rd"name="pwd"/>
<b种缩批防乙r>
<inputtype="submit"value="提交"/>
</form>
</body>
</html>
上面的这些是登陆页
publi执发她又cvoiddoGe操晚控缩双征乡包照t(h**ttpServletRequestrequest错即坏,h**ttpServletResponseresponse)
throwsServletException,IOException{
this.doPost(request,response);
}
/**
*ThedoPostmethodoftheservlet.<b响过妈片单胞适r>
*
*Thismethodiscalledwhenaf衡客劳即目ormhasitstagvaluemethodequalstopost.
*
*@paramrequesttherequestsendbytheclienttotheserver
*@paramresponsetheresponsesendb祖矛入政般ytheservertotheclient
*@throwsServletExceptionifanerroroccurred
*@throwsIOExceptionifanerroroccurred
*/
publicvoiddoPost(h**ttpServletRequestrequest,h**ttpServletResponseresponse)
throwsServletException,IOException{
response.setContentType("text/html;charset=utf-8");
request.setCharacterEncoding("utf-8");
Stringname=request.getParameter("name");
Stringpwd=request.getParameter("pwd");
if("admin".equals(name)&&"000".equals(pwd)){
response.sendRedirect("success.jsp");
}else{
response.sendRedirect("fault.jsp");
}
}
这是servlet代码
至于success.jsp和fault.jsp
只需要在body分别打上欢迎登陆或者登陆失败就行了