-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3684190
By: nobody
Hello,
In a function i have written following code for seting session attribute
(Sessions.getCurrent()).setAttribute(UserName,name.value);
(Sessions.getCurrent()).setAttribute(Language,CmbLang.value);
alert( "Welcome :"+ rs.getString("LSU_USER_NAME_C"));
alert((Sessions.getCurrent()).getAttribute(UserName));
Executions.sendRedirect ("Session2.zul");
it is displaying user name properly but in session2.zul
i have written code to extract UserName attribute as follows:- B.value=(String)(Sessions.getCurrent()).getAttribute(UserName);
but here i am getting blank value Please kindly tell me how to correct this code. I have written that much code only for creating session.
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3684775
By: henrichen
It should work.
What is UserName? Where is the UserName come from in the session2? Please provide a "reduced" zuml code and it would be easier for us to replicate the bug.
/henri
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3691806
By: tanya20
session attribute not working properly.
Login.zul
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection(url,"Employee","employee123");
Statement st=con.createStatement();
String pwdquery="Select user_id,pwd From employee where LSU_USER_ID_C = '"+name.value+"'";
ResultSet rs=st.executeQuery(pwdquery);
String DbPasswd;
if(rs.next())
{
DbPasswd=rs.getString("LSU_ENCRYPTED_PASSWD_C");
if(DbPasswd.equals(Pass))
{
(Sessions.getCurrent()).setAttribute(name,name.value);
alert((Sessions.getCurrent()).getAttribute(name));
Executions.sendRedirect ("Sess_log_1.zul");
}
else
{
alert("UserId/Password is Incorrect");
clear();
}
}
con.close();
}catch(SQLException error)
{
alert("Sql Error");
}
in Sess_log_1.zul
String name;
B.value=(String)(Sessions.getCurrent()).getAttribute(name);
but its not working i am getting null value for name in Sess_log_1.zul but in Login.zul alert((Sessions.getCurrent()).getAttribute(name)); is displaying the user name.
Plaese tell how to create session if the way i am doing is wrong.
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3691939
By: tomyeh
Did you mean setAttribute("name", name.value) and getAttribute("name")?
BTW, you seem forget to close connection at the finally clause:)
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3691957
By: tanya20
i tried even after changing setAttribute("user",name.value) and getAttribute("user")
and i am closing connection just before end of try block.
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3692047
By: tomyeh
Closing connection at try block is not good enough. For example, a NullPointerException makes the connection remaining open.
ZK's session is simple wrap of HttpSession. You might take a look at the source
codes: com.potix.zk.ui.http.SessionImpl.
BTW, what Web server do you use?
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3692101
By: henrichen
Change your code a little bit:
Login.zul
...
(Sessions.getCurrent()).setAttribute("user",name.value);
alert((Sessions.getCurrent()).getAttribute("user"));
...
in Sess_log_1.zul
B.value=(String)(Sessions.getCurrent()).getAttribute("user");
Session attribute is in fact a Map. You have to provide same _KEY_ to fetch that value.
/henri
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3693335
By: tanya20
Thanks Tom , i am using Tomcat 5.5 u aksed me to see the source codes but no code is availble thr only declartaion of classes and functions are available from where i can find the whole code.
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3693339
By: tanya20
Thanks henri,
Now session is working properly.
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3693399
By: henrichen
Glad to know your problem solved.
/henri
Asked: 2006-04-13 06:06:46 +0800
Seen: 746 times
Last updated: Apr 19 '06