Personally, I'd use SessionAware and reduce coupling even further.

The docs for both methods should answer this question fairly completely.

The session is exposed as a map in S2, and as a servlet spec artifact in S1.

Dave



On Wed, May 8, 2013 at 12:15 PM, john lee <sh_thorn_b...@yahoo.com> wrote:

>
> for stuts 1, to get session, via the following
>
>       session=request.getSession();
>       session.setAttribute("PERSON", person);    /* person is object name
> */
>
> for struts 2, to get session, via the following
>
>       Map session=ActionContext.getContext().getSession();
>       session.put("PERSON", person);    /* person is object name */
>
> question is
>
>     for struts2: if i use the following
>           session.setAttribute("PERSON", person);
>     then compile to get following error
>
>                cannot find symbol
>                        symbol  : method
> setAttribute(java.lang.String,neuco.Person)
>                         location: interface java.util.Map
>                         session.setAttribute
>
>    is that means for struts2, when i use session, i have to use
> session.put, but session.setAttribute is no longer valid?
>    what is the difference b/w session.put and session.setAttribute?
>
> thanks in advance
>
> john




-- 
e: davelnew...@gmail.com
m: 908-380-8699
s: davelnewton_skype
t: @dave_newton <https://twitter.com/dave_newton>
b: Bucky Bits <http://buckybits.blogspot.com/>
g: davelnewton <https://github.com/davelnewton>
so: Dave Newton <http://stackoverflow.com/users/438992/dave-newton>

Reply via email to