0

How to store login information

asked 2009-01-11 07:15:10 +0800

MatthewWu gravatar image MatthewWu
9 1

Users login ZK via username & password
if we want to use username in the future after users log in.
where i can store username information?
(I think we can set session or request parameters in old JSP code)

delete flag offensive retag edit

6 Replies

Sort by ยป oldest newest

answered 2009-01-11 08:47:23 +0800

oberinspector gravatar image oberinspector
219 2 2

I use the session to store login information as a session attribute. Session is accessible from zul and from java.

link publish delete flag offensive edit

answered 2009-01-13 01:13:07 +0800

dennis gravatar image dennis
3679 1 6
http://www.javaworld.com....

ZK has its own session and application scope object and they wrap original HTTP session and application to set/get Attribute

link publish delete flag offensive edit

answered 2009-01-25 09:44:47 +0800

steenjunus gravatar image steenjunus
6

updated 2009-01-25 09:46:25 +0800

Hi, I have scenario where I store an object created in a servlet in session using

getServletContext().setAttribute("myString", strValue);

In another class extending org.zkoss.zul.Window, called either from onSelect() of treeitem or load of page. I cannot figure out how to get the value. I tried with:

Session s = Sessions.getCurrent();
s.getAttribute("myString");

but it always return null. What am I doing wrong?

I would like to be able to get hold of the full HttpSession and HttpRequest from my Zk classes. Can anyone tell me how to do that?

Thanks,
Steen

link publish delete flag offensive edit

answered 2009-01-25 11:05:40 +0800

mjablonski gravatar image mjablonski
1284 3 5
http://www.jease.org/

updated 2009-01-25 11:05:51 +0800

Hi Steen,

getServletContext().setAttribute("myString", strValue);

you're storing myString in the ServletContext which is not the Session... so you should fix this in first place.

If you want to access the native HttpSession, you can use Sessions.getCurrent().getNativeSession().

HTH, Maik

link publish delete flag offensive edit

answered 2009-01-25 15:22:32 +0800

marcobuss gravatar image marcobuss
12

In a class that extends a component you can use
getAttribute("paramKey", SESSION_SCOPE); to receive an Attribute from the Session or another Scope and
setAttribute("paramKey", objectToSaveToSession, SESSION_SCOPE); to save an Attribute to the Session.

link publish delete flag offensive edit

answered 2009-01-25 19:39:04 +0800

steenjunus gravatar image steenjunus
6

Yes, a couple of hours after my post I realized my mistake; storing myString in ServletContext and trying to read from Session.
Thanks for your fast reply though,
Steen

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: 2009-01-11 07:15:10 +0800

Seen: 417 times

Last updated: Jan 25 '09

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