Okay. I'm not a super-duper-cool-Java-coder. I'm still learning. My main problems always arise from trying expressions/variables/stuff from other languages and not having it work. And let me tell you, JSP(Java Server Pages) Error Messages are the most cryptic fucking annoying things in the world.
So, to get to the point. I have a variable I was passing in. To sort a table. So I had to do two things. 1) See if the variable existed, and if not, give it a default value. 2) If it did, in fact, exist, assign the table name that the SQL(Structured Query Language) was going to call in the query.
Silly me, I thought that if (variable == "passedInVariable") would work. Stupid me. I mean, sure, it works for if variable != null). But not for checking to see if two strings are the same.
if (variable.equals("FOO"))
NewVariable = "tableFOO";
else if (variable.equals("BAR"))
NewVariable = "tableBAR";
else
NewVariable = "tableDEFAULT";
Yup. variable.equals("text") is the key.
Tagged As Coding
Comments are Open (4)
Posted at 03:13 PM
Comments
Lucas
Thank you for posting this. I've been dicking around with the same problem for the past hour.
Posted by: Lucas | April 14, 2003 08:56 PM
Tony
Glad I could help. Whenever I run across some problem that's been kicking my ass like this, I generally try and post my solution, if I remember. Remembering is the key.
Posted by: Tony | April 15, 2003 08:33 AM
eddie
Thank you for that!
I spend hours of hours trying to make a script with the wrong syntaxis...
eddie.
Posted by: eddie | August 21, 2003 09:40 PM
amanda
LoL hey thanks, man ;) u's tops!
Posted by: amanda | January 31, 2004 01:23 PM