Hi,

What's the best practice to refer to request and session within an S2 Action
without tying it to HttpServletRequest or HttpSession ?

Assume that we need to capture values from certain request parameters and do
some processing based on them, and set session attributes :

Currently, i'm doing it like :

HttpServletRequest request = ServletActionContext.getRequest();
HttpSession session = request.getSession(true);
if (null != request.getParameter("param1"))
session.setAttribute("attr1" , true);
else
session.setAttribute("attr1" , false);

This works, but we now have references to HttpServletRequest and HttpSession
which goes against the S2 "POJO" action / testability benefits etc. (even
though i may not write a TestCase at all)

What's the best way to do this, so that the Action remains independent of
http ?

Thanks,
Joseph

Reply via email to