LogBean.java文件
package login;
import java.util.*;
public class LogBean
{
private String username;
private String password;
private String email;
private Hashtable errors;
public LogBean()
{
username=" ";
password=" ";
email=" ";
errors=new Hashtable();
}
public String getUsername()
{
return username;
}
public String getPassword()
{
return password;
}
public String getEmail()
{
return email;
}
public void setUsername(String name)
{
username=name;
}
public void setPassword(String pass)
{
password=pass;
}
public void setEmail(String mail)
{
email=mail;
}
public void setErrors(String key,String msg)
{
errors.put(key,msg);
}
public boolean validate()
{
boolean ok=true;
if(username.equals(" "))
{
errors.put("username","please input your name");
username=" ";
ok=false;
}
if(password.equals(" ")||(password.length()>10||password.length()<6))
{
errors.put("password","please input a password with length of 6-10 characters");
password=" ";
ok=false;
}
return ok;
}
public String getErrorMsg(String message)
{
String errorMsg=(String)errors.get(message.trim());
return((errorMsg==null) ? " ":errorMsg);
}
}
logcm.jsp文件
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<jsp:useBean id="loginfo" class="login.LogBean" scope="request"/>
<jsp:setProperty name="loginfo" property="*"/>
<title>信息验证</title>
</head>
<body>
<%
if(loginfo.validata())
{
%>
<jsp:forward page="success.jsp"/>
<%
}
else{
%>
<jsp:forward page="relog.jsp"/>
<%
}
%>
</body>
</html>
relog.jsp文件
<jsp:useBean id="loginfo" class="login.LogBean" scope="request"/>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>输入错误</title>
</head>
<body>
<p align="center"><font color="#FF0000">登录错误!</font></p>
<p align="center"><%=loginfo.getErrorMsg("username") %></p>
<p align="center"><%=loginfo.getErrorMsg("password") %></p>
<p align="center"><%=loginfo.getErrorMsg("email") %></p>
<form method="post action="login.jsp">
<p align="center"><input type="submit" value="确定" name="B1"></p></form>
</body>
</html>
success.jsp文件
<jsp:useBean id="loginfo" class="login.LogBean" scope="request"/>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>登录成功</title>
</head>
<body><p align="center">登录成功!你输入的信息为:</p>
<p align="left">姓名:
<jsp:getProperty name="loginfo" property="username"/>
</p>
<p align="left">密码:<jsp:getProperty name="loginfo" property="password"/></p>
<p align="left">EMAIL:<jsp:getProperty name="loginfo" property="email"/>
</p>
</body>
</html>
login.jsp文件
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>JavaBean在JSP中的运用</title>
</head>
<body>
<form method="post" action="logcm.jsp">
<p align="center">请登录</p>
<p align="center">用户名:<input type="text" name="username" size="20"></p>
<p align="center">密码: <input type="password" name="password" size="20"></p>
<p align="center">EMail: <input type="text" name="email" size="20"></p>
<p align="center"><input type="submit" value="提交" name="B1"><input type="reset" value="重写" name="B2"></p></form>
</body>
</html>
是通过login.jsp调用javaBean的
我已将LogBean.java编译好的.class文件放入commom/classes/login文件夹中
我刚学实在看不出那错了,请大家给个具体的解决办法把