0

Access request from SessionInit

asked 2011-10-18 21:53:18 +0800

RichardL gravatar image RichardL
768 4

Hi all,
I'd like to be able to get cookie information at the start of the session but the request object (Executions.getCurrent().getNativeRequest()) is null. Here is the code I'm using:

public class SessionInitiator implements SessionInit {

    public void init(Session sn, Object o) throws Exception {
       //no request variable to access yet, can't access cookies from here
       Cookie[] cookies = ((HttpServletRequest) Executions.getCurrent().getNativeRequest()).getCookies();
        
    }
}

Any ideas?

delete flag offensive retag edit

3 Replies

Sort by ยป oldest newest

answered 2011-10-19 20:22:22 +0800

RichardL gravatar image RichardL
768 4

Nobody...?

Just so you know why I want to get cookies in my SessionInit: I'd like to be able to see if a user is "remembered" with cookies, and if so update a last visited date in my database, rather than doing so at user login.

link publish delete flag offensive edit

answered 2011-10-20 00:16:10 +0800

gekkio gravatar image gekkio flag of Finland
899 1
http://gekkio.fi/blog

updated 2011-10-20 00:16:38 +0800

If you look at the Javadoc, you'll see that the method signature is:

void init(Session sess, java.lang.Object request)

So, in your code the request is Object o and you can cast it to HttpServletRequest.

link publish delete flag offensive edit

answered 2011-10-20 08:35:38 +0800

RichardL gravatar image RichardL
768 4

Oh, thanks.

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2011-10-18 21:53:18 +0800

Seen: 223 times

Last updated: Oct 20 '11

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More