文档介绍:作者:Eazily
email: Eazily@
日期:6/12/2001 2:50:16 PM
form处理、动态内容和bean通信
列表4展示了一个具体的JSP JavaBean--LoginJSPBean,用来实现特定的页面处理
列表4。LoginJSPBean
package ;
import .*;
import .*;
public class LoginJSPBean extends AbstractJSPBean {
public static final String PAGE_CODE = "login";
private String _voterId;
private String _password;
private Voter _voter = null;
public LoginJSPBean() {
}
public void setVoterId (String newVoterId) {
_voterId = newVoterId;
}
public String getVoterId() {
if (_voterId == null) return "";
else return _voterId;
}
public void setPassword (String newPassword) {
_password = newPassword;
}
public String getPassword() {
if (_password == null) return "";
else return _password;
}
public Voter getVoter () {
return _voter;
}
protected void beanProcess () throws {
if (_voterId == null || ("")) {
addErrorMsg("Voter must be entered");
}
if (_password == null || ("")) {
addErrorMsg("Password must be entered");
}
if (getState() != ERR) {
file://If all the fields are entered, try to login the voter
Voter voter = (_voterId, _password);
if (voter == null) {
addErrorMsg("Unable to authenticate the Voter. Please try again.");
}
else {
_voter = voter;
if (() != null) {
// if the voter has already voted, send the voter