Begining JSP Web Development外文书籍源代码
源代码在线查看: user2.java
package com.wrox.errors;
import java.beans.*;
import javax.servlet.jsp.PageContext;
import javax.servlet.http.HttpSession;
import java.lang.Exception;
public class User2 extends Object implements java.io.Serializable {
public User2() {}
private String username;
private String password;
public void setUsername(String name) {
username = name;
}
public String getUsername() {
return username;
}
public void setPassword(String pass) {
password = pass;
}
public void validateUser() throws Exception, NullPointerException {
if ((username == null) || (password == null)) {
NullPointerException trouble = new NullPointerException
("Must supply a username and password!");
throw trouble;
}
if (!(username.equals("Casey") && password.equals("Kochmer"))) {
Exception trouble = new Exception("Couldn't validate your password!");
throw trouble;
}
}
}