I am fairly new to Java EE. I was going through CDI and EJB material and came across @SessionScoped and @Stateful annotation.
Looking at the definition : @SessionScope: A user’s interaction with a web application across multiple HTTP requests is maintained.
@Statfeful : looks like it has the same functionality as @SessionScope
So here are my doubts :
1) Do both of them serve the same purpose ? 2) I have a bit of experience with Node and Python. In those languages for maintaining client state I always used a cookie which is tied to an HTTPSession object which is further tied to an in-memory cache(redis/memcache) for distribution across all the servers.
So I can use the same technique here as well... correct ? Then why should I use these notations ? Also, if I plan to use them, then how to make them distributed across all servers? I mean a request from client can come to server1 and then next request can go to server2 ..in that case if this SesssionScoped object is not distributed then how will things work correctly ?
What is the purpose of these annotation ?