|
 |
pro_jsp thread: Problems with Sessions!
Message #1 by "Al Higgs" <al.higgs@b...> on Thu, 28 Feb 2002 19:19:48
|
|
Al,
This is not a session issue but a java issue. Remember java has two equals
==(!=) and xxx.equals(yyy).
Here you are looking at the values of two strings. So you should use if
("administrator".equals(acesslevel)) to check the value. The first one !=
is checking the reference.
Bin
>From: "Al Higgs" <al.higgs@b...>
>Reply-To: "Pro_JavaServer_Pages" <pro_jsp@p...>
>To: "Pro_JavaServer_Pages" <pro_jsp@p...>
>Subject: [pro_jsp] Problems with Sessions!
>Date: Thu, 28 Feb 2002 19:19:48
>
>Hello,
>
>Im new to JSP and I seem to be having some problems with sessions, ill
>quickly explain the problem.
>
>On a page i have set a session called "user", which has got an
>attribute called "Access". What i want to do is define whether that
>attribute is equal to "Administrator". If it is i want to show a form, if
>not show some error message. But storing the value into a string seems to
>be giving problems.
>
>However i can display the value of "Access" if i use
>
><%=session.getAttribute("Access")%>
>
>So why doesnt the following work??
>
><%
>String accesslevel;
>accesslevel = session.getAttribute("Access");
>
>if (accesslevel != "administrator")
>{
>out.print("Show Administrator Stuff Here");
>}
>else
>{
>out.print("Show non Administrator Stuff instead");
>}
>%>
>
>I really appreciate any input
>
>Thanks
>
>Al
Bin Zhou
_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com
|
|
 |