Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

retrieving a session variable

Status
Not open for further replies.

InfoCorp

Programmer
Mar 18, 2004
10
0
0
US
I am trying to retrieve a session variable and then check the value of that variable inside an if statement. I am getting an error saying that you incompatiable aperand types string and char. What am I doing wrong? The code follows. Thanks for the help.

function Init()
{
<%String simgenb = (String)session.getAttribute("simgenb");
if(simgenb == 'Y')
{%>
document.Detail.Image.hidden = False
document.Detail.Image.disabled = False

document.Detail.Picture.hidden = False
document.Detail.Picture.disabled = False

document.Detail.Map.hidden = False
document.Detail.Map.disabled = False
<%}%>
}
 
Do you need double quotes to make "Y" into a string?
 
I would suggest you change the if test to be like this:
Code:
if (simgenb.equals("Y"))
because in Java a String is an object and the == won't always work. I would be better to use the Java tools that are available for Strings.

Einstein47
(&quot;The pure and simple truth is rarely pure and never simple.&quot; - Oscar Wilde)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top