扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:QQ新人类 来源:yesky 2007年10月30日
关键字:
package lbm.examples; import lbm.jsputil.*; import java.util.*; 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 java.io.IOException { if (_voterId == null || _voterId.equals("")) { addErrorMsg("Voter must be entered"); } if (_password == null || _password.equals("")) { addErrorMsg("Password must be entered"); } if (getState() != ERR) { file://If all the fields are entered, try to login the voter Voter voter = VoteDB.login(_voterId, _password); if (voter == null) { addErrorMsg("Unable to authenticate the Voter. Please try again."); } else { _voter = voter; if (_voter.getVotedForCandidate() != null) { // if the voter has already voted, send the voter to the last page redirect("confirmation.jsp"); } else { // go to the Vote page redirect("vote.jsp"); } } } } protected void beanFirstPassProcess() throws java.io.IOException { } protected void beanFooterProcess() throws java.io.IOException { } protected String getJSPCode() { return PAGE_CODE; } } |
protected void beanFirstPassProcess() throws java.io.IOException { // get the Voter from Login page _voter = null; LoginJSPBean loginJSPBean = (LoginJSPBean) getSharedSessionBean().getJSPBean(LoginJSPBean.PAGE_CODE); if (loginJSPBean != null) { _voter = loginJSPBean.getVoter(); } if (_voter == null) { // voter is not logged in yet. Send it to Login page setState(NEW); redirect("login.jsp"); } } |
public String getCandidateList () { StringBuffer candidateList = new StringBuffer(); Candidate candidate; Iterator candidates = VoteDB.getCandidates(); while (candidates.hasNext()) { candidate = (Candidate) candidates.next(); candidateList.append("<input type=radio name=\"candidateName\" value=\""); candidateList.append(candidate.getName()); candidateList.append("\"> "); candidateList.append(candidate.getName()); candidateList.append("<br>\n"); } return candidateList.toString(); } |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者