<%@ include file="inc.jsp" %>
<%
String username = request.getParameter("username");
String password = request.getParameter("password");
if(username == null || password == null){
response.sendRedirect("index.jsp");
}
boolean isValid = false;
String sql = "select * from user where username='"+username+"'and password='"+password+"'";
out.println("===>"+sql);
try{
Class.forName(drv).newInstance();
Connection conn = DriverManager.getConnection(url, usr,pwd);
Statement stm = conn.createStatement();
ResultSet rs = stm.executeQuery(sql);
if(rs.next())isValid = true;
rs.close();
stm.close();
conn.close();
}catch(Exception e){
e.printStackTrace();
out.println(e);
}
if(isValid){
response.sendRedirect("welcome.jsp");
}else response.sendRedirect("index.jsp");
%>
<% /*
if(username.endsWith("a"))response.sendRedirect("welcome.jsp");
else response.sendRedirect("index.jsp");
*/%>
|