When should SessionMap be used instead of Map?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

When should SessionMap be used instead of Map?

albert kao-2
I am looking for an example that SessionMap should be used instead of Map.

In the Struts 2 Getting Started HTTP Session tutorial (
https://struts.apache.org/getting-started/http-session.html),
HelloWorldAction.java used
private Map<String, Object> userSession;

I used SessionMap to replace Map.
i.e.
private SessionMap<String, Object> userSession;

I got the same result after I compiled & executed the modified program, so
this is not an example to show the difference between SessionMap and Map.
Reply | Threaded
Open this post in threaded view
|

Re: When should SessionMap be used instead of Map?

Lukasz Lenart
2017-12-08 2:06 GMT+01:00 albert kao <[hidden email]>:

> I am looking for an example that SessionMap should be used instead of Map.
>
> In the Struts 2 Getting Started HTTP Session tutorial (
> https://struts.apache.org/getting-started/http-session.html),
> HelloWorldAction.java used
> private Map<String, Object> userSession;
>
> I used SessionMap to replace Map.
> i.e.
> private SessionMap<String, Object> userSession;
>
> I got the same result after I compiled & executed the modified program, so
> this is not an example to show the difference between SessionMap and Map.

The short answer is: you should not use SessionMap and stick with Map

This an internal implementation that can change at any time and you
shouldn't depend on any concrete implementation but just use the
interface - this is safer.


Regards
--
Ɓukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]