-
FEATURED COMPONENTS
First time here? Check out the FAQ!
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)
I use the session to store login information as a session attribute. Session is accessible from zul and from java.
ZK has its own session and application scope object and they wrap original HTTP session and application to set/get Attribute
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");
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
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
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.
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
Asked: 2009-01-11 07:15:10 +0800
Seen: 417 times
Last updated: Jan 25 '09