public class LoginAction extends ActionSupport {
private String username;
private String password;
@Override
public String execute() throws Exception {
ActionContext ctx = ActionContext.getContext();
Integer counter = (Integer)ctx.getApplication().get("counter");
// put counter into application
ctx.getApplication().put("counter", counter);
// put username into session
ctx.getSession().put("user", username);
if (getUsername().equals("crazyit.org")
&& getPassword().equals("leegang")) {
ctx.put("tip", "Login Success! ");
return SUCCESS;
}
else {
ctx.put("tip", "Login Falied!");
return ERROR;
}
}
}
I put "counter"
in application "user"
in session and "tip"
in ActionContext
. In JSP I can use ${session.user}
and ${sessionScope.user}
to reference the "user" property. ${request.tip}
and ${requestScope.tip}
to reference tip
.
My questions:
- Are session, request, application the same as
sessionScope
,requestScope
,applicationScope
in EL? - What's the relationship between
ActionContext
andrequest(requestScope)
?
P.S.:
I test ${request == requestScope}
which is true, this means they are the same?