请问大家这是什么问题,求救啊,看在我是做毕业设计的份上,请高手帮忙啊!!!
login.config.jsp
<%@ page contentType= "text/html; charset=GBK " import= "java.sql.* "%>
<jsp:useBean id= "conndb " scope= "page " class= "dbconn.conndb ">
</jsp:useBean>
<html>
<head>
<title>
login.config
</title>
</head>
<body bgcolor= "#ffffff ">
<%
try{
ResultSet rs=conn.executeQuery( "select * from user_info where Username= ' "+Username+ " ' ");
if(rs.next()){
String Password=request.getParameter( "Password ");
if(Password.equals(rs.getString( "password "))){
session.setAttribute( "UserName ",Username);
response.sendRedirect( "index.jsp ");
}else{
out.println( " <script language= 'javascript '> alert( '您输入的用户名或密码错误,请与管理员联系! ');window.location.href= 'index.jsp '; </script> ");
}
}else{
out.println( " <script language= 'javascript '> alert( '您输入的用户名或密码错误,或您的帐户已经被冻结,请与管理员联系! ');window.location.href= 'index.jsp '; </script> ");
}
}catch(Exception e){
out.println( " <script language= 'javascript '> alert( '您的操作有误! ');window.location.href= 'index.jsp '; </script> ");
}
%>
</body>
</html>
javabean
package dbconn;
import java.sql.*;
import sun.jdbc.odbc.JdbcOdbcDriver;
public class conndb {
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
public conndb() {
try {
Class.forName( "sun:jdbc:odbc:JdbcOdbcDriver ");
} catch (java.lang.ClassNotFoundException e) {
System.err.print(e.getMessage());
}
}
public ResultSet executeQuery(String sql){
try {
conn = DriverManager.getConnection( "jdbc:odbc:mydb ", "sa ", "sa ");
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
} catch (SQLException ex) {
System.err.print(ex.getMessage());
}
return rs;
}
public int executeUpdate(String sql){
int result = 0;
try{
conn=DriverManager.getConnection( "jdbc:odbc:mydb ", "sa ", "sa ");
stmt=conn.createStatement();
result=stmt.executeUpdate(sql);
}catch(SQLException ex){
result=0;
}
return result;
}
public void close(){
try{
if(rs!=null)rs.close();}
catch(Exception e){
e.printStackTrace(System.err);
}
try{
if(stmt!=null)stmt.close();
}catch(Exception e){
e.printStackTrace(System.err);
}
try{
if(conn!=null){
conn.close();
}
}catch(Exception e){
e.printStackTrace(System.err);
}
}
}
login.jsp
<table >
<tr>
<td> 用户名 </td> <td > <input type= "text " name= "Username "/> </td>
</tr>
<tr>
<td> 密 码 </td> <td> <input type= "password " name= "Password "/> </td>
</tr>
<tr>
<td> <input type= "submit " name= "login " value= "登陆 " /> </td> <td > <input type= "button " name= "login " value= "注册 "/> </td>
</tr>
</table>
</form>
<script type= " " language= "javascript ">
function check(){
if(document.reg.Username.value== " "){
alert( "请输入用户名 ");
return false;
}
if(document.reg.Password.value== " "){
alert( "请输入密码 ");
return false;
}
}
</script>
</body>
</html>
错误
"login.config.jsp ": cannot find symbol; symbol : variable Username, location: class org.apache.jsp.login_config_jsp
"login.config.jsp ": cannot find symbol; symbol : variable conn, location: class org.apache.jsp.login_config_jsp
"login.config.jsp ": cannot find symbol; symbol : variable Username, location: class org.apache.jsp.login_config_jsp
[解决办法]
ResultSet rs=conn.executeQuery( "select * from user_info where Username= ' "+Username+ " ' ");你 "+Username+ "哪来的呀?你都不定义当然错了
String Password=request.getParameter( "Password ");这个不就定义了吗!把Username和这个一样定义一下。
conn也是一样的。应该 Statement stmt = conn.createStatement();定义了再用
[解决办法]
不要急,毕业设计的朋友,慢慢看,不行就先休息下,不然没灵感的。帮你up
[解决办法]
用request.getParameter( "UserName ")获取上页来的参数哈
[解决办法]
从页面获得用户名,密码,request.getparmeter( "userid "),request.getparmeter( "password "),传入java代码,获得userid ,password,到数据库进行检测,如果有结果,用户名密码正确,没有不正确
[解决办法]
没初始化变量 或者根本没这个变量