求助jsp文件转tag文件之后点登陆一直在刷新,下面是tag文件
<%@ tag pageEncoding="GB2312"%><%@ tag import="java.sql.*"%>
<%@ attribute name="name" required="true"%>
<%@ attribute name="password" required="true"%>
<%@ variable name-given="backMess" scope="AT_END"%>
<% byte[] a=name.getBytes("ISO-8859-1");
name=new String(a);
byte[] b=password.getBytes("ISO-8859-1");
password=new String(b);
String mess="";
try{ Class.forName("com.mysql.cj.jdbc.Driver");
}
catch(Exception e){
out.print(e);
}
Connection con;
Statement sql;
ResultSet rs;
String loginMess=(String)session.getAttribute("name");
if(loginMess==null){
loginMess="******";}
String str=name+","+password;
if(loginMess.equals(str)){
mess="帐号"+name+"已经登录";
}
else{
String url="jdbc:mysql://localhost/shangjiang";
boolean boo=(name.length()>0)&&(password.length()>0);
try{
con=DriverManager.getConnection(url,"root","root");
sql=con.createStatement();
if(boo){
rs=sql.executeQuery("select*from user where name='"+name+"'and password='"+password+"'");
boolean m=rs.next();
if(m==true){
response.sendRedirect("ok.jsp");
}
else{
response.sendRedirect("fail.jsp");
}
}
else{mess="请输入用户名和密码";}
con.close();
}
catch(Exception exp){
mess="异常情况"+exp;
}
}
jspContext.setAttribute("backMess",mess);
%>