0

get a Session from ZK

asked 2010-04-08 09:00:37 +0800

ibsolution gravatar image ibsolution
468 1 1 6

Hai,

how can i read a session using a servlet, after it set with a ZK

this code is to use a standard httpsession using a ZK
HttpSession session = (HttpSession)(Executions.getCurrent()).getDesktop().getSession().getNativeSession();
session.setAttribute("key",userObject);

but when i try to read a that value using this :

HttpSession session = req.getSession(true);
UserObject userObj = (UserObject)session.getAttribute("key");
if (userObj != null){
session.setAttribute("key", userObj);
session.setMaxInactiveInterval(-1);
}

userObj always return null value. What happen ?

TIA,

Andy Susanto

delete flag offensive retag edit

5 Replies

Sort by ยป oldest newest

answered 2010-04-08 14:54:38 +0800

caclark gravatar image caclark
1753 2 5
http://clarktrips.intltwi...
Have you tried checking to see if your sessions are the same?
HttpSession session = (HttpSession)(Executions.getCurrent()).getDesktop().getSession().getNativeSession();
session.setAttribute("key",userObject);
System.out.println( "Wrote to session:" + session.getId() ) ;
HttpSession session = req.getSession(true);
if ( session.isNew() )
   System.out.println( "Hi!  I'm a new session:" + session.getId() ) ;
else
   System.out.println( "Hi!  I'm old session:" + session.getId() ) ;
link publish delete flag offensive edit

answered 2010-04-08 19:48:18 +0800

ibsolution gravatar image ibsolution
468 1 1 6

Hai,

yes i got different session id
ZK 9FEB16C85A02835870DA62000E53A091
standard AAA25BC04CB9F42280198BA850738B83

how can get a session id from a ZK ?

TIA,

Andy Susanto

link publish delete flag offensive edit

answered 2010-04-09 07:33:50 +0800

caclark gravatar image caclark
1753 2 5
http://clarktrips.intltwi...

Something's invalidating the session and causing your HttpSession session = req.getSession(true); to think it needs to create a new one. Having not seen all your code, it's hard to say. You should be able to boil it down to very minimal code to either find out what the problem is or have a shareable set of code to file with a bug report.

link publish delete flag offensive edit

answered 2010-04-10 09:32:30 +0800

ibsolution gravatar image ibsolution
468 1 1 6

updated 2010-04-10 09:37:43 +0800

Hai,

i just use a simple code

first create a servlet with a button, button action only create a session and call ZK page.

at ZK page. just create a button, and the action just put a session then call a servlet page.

for the first try it is ok, try to second you will get a different session ID

just like that. i am using zk 3.6.4

Regards,

Andy Susanto

link publish delete flag offensive edit

answered 2010-04-11 22:30:58 +0800

fngaserin gravatar image fngaserin
24

Post your code Andy. Maybe we can dig into it a little bit.

Felix Ngaserin

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: 2010-04-08 09:00:37 +0800

Seen: 2,224 times

Last updated: Apr 11 '10

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