LoginAction.java
public class LoginAction extends Action {
??? public ActionForward execute(
???????????????????????????? ActionMapping mapping,
???????????????????????????? ActionForm form,
???????????????????????????? HttpServletRequest request,
???????????????????????????? HttpServletResponse response)
??????????????????????????????????? throws Exception {
??????? String username = ((UserForm) form).getUsername();
??????? String password = ((UserForm) form).getPassword();
???????
??????? request.setAttribute("username", username);
???????
??????? if(username.equals("freefly") &&
????????????????? password.equals("whl")) {
??????????? return mapping.findForward("helloUser");
??????? }
???????
??????? return mapping.findForward("loginFail");
??? }
}
2.hello.jsp
<html>
<head>
<title>Hello, ${username} !</title>
</head>
<body>
<H1>Hello, ${username} !</H1>
<H1>This is your secret gift!!</H1>
</body>
</html>