Hey, I'm having a problem with an if statement. I want to check if variable key and id are the same. They are both strings and when I print them to screen they certainly look the same. However when using them within an if statement it always returns false. Here is my code, I have commented where the statement is not reverting true when it should. Thanks for your help:
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ include file="connection.jsp" %>
<html>
<head>
<title>Web hosting FAQ</title>
</head>
<body>
<center><h1>Customer area</h1></center>
Frequently asked questions about web hosting: <br />
<%
String key = null;
key = request.getParameter("question");
String id = null;
String Question = null;
String Answer = null;
String Updated = null;
String Author = null;
ResultSet columns1 = statement.executeQuery("SELECT * FROM Questions");
while(columns1.next())
{
id = columns1.getString("ID");
Question = columns1.getString("Question");
Answer = columns1.getString("Answer");
Updated = columns1.getString("Timestamp");
Author = columns1.getString("Author");
if (id == key)
{
out.print("This statement should be true!);
}
%>
<a href="custarea.jsp?question=<%=id %>"><%=Question %></a> <br />
<%
} %>
</body>
</html>