|
-
Sep 7th, 2004, 02:56 PM
#1
Thread Starter
Fanatic Member
If statement not working WHY????????
I have the following within a JSP, and all I am trying to do is compare the values that are returned by request.getParameter..
Code:
<%
String name = request.getParameter("Name");
String dept = request.getParameter("Department");
String mgr = request.getParameter("Manager");
String q1 = request.getParameter("q1");
String q2 = request.getParameter("q2");
String q3 = request.getParameter("q3");
String a1 = request.getParameter("a1");
String a2 = request.getParameter("a2");
String a3 = request.getParameter("a3");
ddpe.sqltools.SQLTool q= new ddpe.sqltools.SQLTool("sun.jdbc.odbc.JdbcOdbcDriver","MysteryWeb",true);
q.doSelectQuery("INSERT INTO Mystery VALUES('"+name+"', '"+dept+"', '"+mgr+"', '"+q1+"', '"+q2+"', '"+q3+"')");
//out.println(q.getError());
//out.println(a1);
//out.println(q1);
q.close();
%>
<font size=3 color="990033"><b>1. </b></font><font size=3 color="330099"><b>If a customer has a question on a Business Card, which of the following numbers do you use to warm transfer?:</b></font>
<p>
<%
if (q1=="866-341-5203 - Correct")
out.println("<font size=3><b>Your answer to question # 1 was</font><font color='red'> INCORRECT!</font><p><font color='blue'></b><b> The correct answer is - 866-341-5203 </b></font><p>");
else
out.println("<font size=3 color='blue'><b>You answered question # 1 CORRECT!</b></font>");
%>
<font size=3 color="990033"><b>2. </b></font><font size=3 color="330099"><b>When Cold Transfer is in effect, does this mean that you can cold transfer to the Branches?:</b></font>
<br>
<%
if (q2!="Yes - Correct")
out.println("<font size=3><b>Your answer to question # 2 was</font><font color='red'> INCORRECT!</font><P><font color='blue'></b><b> The correct answer is - Yes </b></font><p>");
else
out.println("<font size=3 color='blue'><b>You answered question # 2 CORRECT!</b></font>");
%>
<font size=3 color="990033"><b>3. </b></font><font size=3 color="330099"><b>If a customer calls to do a wire transfer over the phone, you should :</b></font>
<br>
<%
if (q3!="Inform of Procedures - Correct")
out.println("<font size=3><b>Your answer to question # 3 was</font><font color='red'> INCORRECT!</font><P><font color='blue'></b><b> The correct answer is - Explain the procedures on how to fax their request with their TAC</b></font><p>");
else
out.println("<font size=3 color='blue'><b>You answered question # 3 CORRECT!</b></font>");
%>
The if statments are not working properly...I do not know why...can someone please enlighten me??
Thank you!
Last edited by Dilenger4; Oct 7th, 2004 at 05:06 PM.
-
Sep 7th, 2004, 04:49 PM
#2
You have to use equals to compare strings.
On a side note, the font tag is deprecated, outdated and lacks any semantic information.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Sep 8th, 2004, 07:16 AM
#3
Thread Starter
Fanatic Member
So CornedBee, would the correct if statment then be like this:
If (q1.equals"866-341-5203 - Correct")
out.println("do something");
else
out.println("do something else");
....if that is the case how is it supposed to be written for not equal???
I am just learning JAVA, and any help will be GREAT!!!
Thank you!
-
Sep 8th, 2004, 07:32 AM
#4
if(!q2.equals("Yes - Correct!"))...
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Sep 8th, 2004, 12:33 PM
#5
Thread Starter
Fanatic Member
THAT"S GREAT!!!
Thank you very much CornedBee!!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|