问题描述
LOGIN.JSP<%@pagecontentType="text/html;charset=gb2312"language="java"import="java.util.*,java.text.*"import="java.sql.*"%><jsp:useBeanid="dbc"scope="session"class="MyBean.dbcon"/><html><head><metahttp-equiv="Content-Type"content="text/html;charset=gb2312"><title>无标题文档</title><styletype="text/css"><!--.style19{color:#FFFFFF}body{margin-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;}a:link{text-decoration:none;}a:visited{text-decoration:none;}a:hover{text-decoration:none;}a:active{text-decoration:none;}--></style><scriptlanguage="javascript">functiontrim(str)//去掉字符串的首尾空格{vartmpStr=newString(str)returntmpStr.replace(/(^s*)|(s*$)/g,"");}functioncheck(){if(trim(form.id.value)==""){alert("用户名不能为空!");form.id.value="";form.id.focus();returnfalse;}if(trim(form.pass.value)==""){alert("用户密码不能为空!");form.pass.value="";form.pass.focus();returnfalse;}}</script><linkhref="Style.css"rel="stylesheet"type="text/css"></head><body><formname=formmethod="post"action="chklog.jsp"onsubmit="returncheck()"><tablewidth="224"height="334"border="0"><tr><tdwidth="178"height="36"bordercolor="#000000"bgcolor="#0D81CA"><divalign="center"class="cssstyle11style9"><divalign="center"class="baise">管理员登录</div></div></td><tdwidth="36"rowspan="5"><imgsrc="images/layout_20.gif"width="36"height="292"align="middle"></td></tr><tr><tdheight="32"bordercolor="#000000"bgcolor="#CC9900"><spanclass="css"><inputname="id"type="text"size="15"><spanclass="baise">用户名</span></span></td></tr><tr><tdheight="32"bordercolor="#000000"bgcolor="#CC9900"><inputname="pass"type="password"size="15"><spanclass="baise">密码</span></td></tr><tr><tdheight="37"bordercolor="#CCCCCC"bgcolor="#FFFFFF"><divalign="right"><inputname="imageField"type="image"src="images/login_btn.jpg"width="82"height="55"border="0"></div></td></tr></table></form></body></html>CHKLOG.JSP<%@pagecontentType="text/html;charset=gb2312"language="java"import="java.util.*,java.text.*"import="java.sql.*"%><jsp:useBeanid="dbc"scope="session"class="MyBean.dbcon"/><html><head><metahttp-equiv="Content-Type"content="text/html;charset=gb2312"><title>公交查询</title></head><body><%request.setCharacterEncoding("gb2312");ResultSetrs=null;//记录集Stringsql="";Stringmyid=request.getParameter("id");Stringmypass=request.getParameter("pass");sql="select*fromuserwhereid='"+myid+"'andpass='"+mypass+"'";rs=dbc.executeQuery(sql);response.sendRedirect("admin/list.jsp");%>