Monday, 5 March 2018

How to use values in sessions ?


Use @SessionScope annotation.

EXAMPLE
@SessionScope(proxyMode=ScopedProxyMode.TARGET_CLASS)
public class User {
    private int value = new Random().nextInt(1000);

    // Getters and setters
}

Data inside User class will be available for the specific session.
For example, Request from same user browser instance will be considered in same session by default.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.