so i was writing a
servlet that has to do some
string comparision (related to DB2 database query)
in the the dopost() method the following code is there :
String a="A";
out.println(rs.getString(3));
if(rs.getString("type1").equals(a)){
RequestDispatcher view=request.getRequestDispatcher("adminlogin.jsp");
view.forward(request, response);
}
else if("B".equals((String)rs.getString(3))){
RequestDispatcher view=request.getRequestDispatcher("customerlogin.jsp");
view.forward(request, response);
}
else if("C".equals((String)rs.getString(3))){
RequestDispatcher view=request.getRequestDispatcher("workerlogin.jsp");
view.forward(request, response);
}
else if("D".equals((String)rs.getString(3))){
RequestDispatcher view=request.getRequestDispatcher("publiclogin.jsp");
view.forward(request, response);
}
out.println(rs.getString("type1"));
out.println(a);
out.println(rs.getString("type1")==a);
the output , as seen in the browser is :
Processing.....!
A
A
A
false
somehow the "A" from the result set doesnt compare with "A" in the servlet
what is wrong here ?