Two Laptop Bag
The moose likes HTML, CSS and JavaScript and the fly likes How to read a False Value Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "How to read a False Value" Watch "How to read a False Value" New topic
Author

How to read a False Value

Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1254
When rf1 = true and rf2 = false I still get the else condition result. What is the syntax for interpreting a false value?

Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15357
    
    6
Are you sure you have a false Boolean and not some other value that is really true?

How are your Booleans being declared?

Eric
Varun Chopra
Ranch Hand

Joined: Jul 10, 2008
Posts: 204

Make sure rf1 = true and rf2 = false, then code will certainly go in if. See below:



Output:

in if


-Varun -
(My Blog) - Mock Tests
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1254
In my servlet I have:



Then in my JSP I have:

Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15357
    
    6
Do yourself a favor and do



Eric
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1254
Returned a value of string.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Your code:




If you put quotes around it, then it's a string.
Non-empty strings are truthy.

Example:


Would show a popup with "true" in it.


Try removing the quotes.
[ November 20, 2008: Message edited by: Ben Souther ]

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1254
Thanks.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15357
    
    6
Just to add what Ben said...

now do



JavaScript was doing the right thing treating your string as true. I recommend you to pick up JavaScript: The Good Parts and read it a few times. [It is short and packed with info, he explains this stuff]

Eric
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: How to read a False Value
 
Similar Threads
Page is Not Refreshing as Expected
Hiding/Showing div elements using Javascript
div not woking
Ternary condition question
Setting radio button value dynamically and rendering partially after ajax request