I am writing a customized interceptor for audit logs purpose. I want to get session attributes and request attributes in interceptor.
For example: I'll set Username
into session and that I am getting too.
But the challenge is: I am defining one bean as audit bean where I am setting some values to bean
if (this.userName.equals("admin")) {
user.setUserName(this.userName);
sessionAttributes.put("USER", user);
auditBean.setPerm("login success");
requestAttributes.put("auditBean", auditBean);
return "success";
} else {
auditBean.setPerm("Login Failed initiaqlized");
requestAttributes.put("auditBean", auditBean);
addActionError(getText("error.login"));
return "error";
}
this request attribute is ServletRequestAware
obj.
But this audit bean I am not able to retrieve into the interceptor, please help regarding this.
Map<String, Object> sessionAttributes = invocation.getInvocationContext().getSession();
achieving session like this.
Map<String, Object> requestAttributes = invocation.getInvocationContext().getParameters();
with above I am not able to retrieve request params. It's showing JSP request params, but not that I have set in action.
You can check that an invocation context in your interceptor is your action context, then get it directly from the context map.
or use alternate syntax