@Override
protected void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// TODO Auto-generated method stub
WorldDBManager DB = new WorldDBManager();
String choices = request.getParameter("selectchoice");
List<WorlPopulationInfo> country = new ArrayList<>();
country = DB.getResultAsArrayList("world", "select * from country");
StringBuffer strB = new StringBuffer();
for(int i=0;i<country.size();i++){
if(country.get(i).countryName == choices){
strB.append("<option selected='selected'>" + country.get(i).countryName+"</option>");
System.out.println(choices + " pareil " + country.get(i).countryName);
}else if(country.get(i).countryName != choices){
strB.append("<option>" + country.get(i).countryName+"</option>");
System.out.println(choices + " " + country.get(i).countryName);
}
}
request.setAttribute("country", strB);
getServletContext().getRequestDispatcher("/index.jsp").forward(request, response);
}
i don't understand why he doesnt go to the first if condition i know the value from variable choices exist inside my database by doing a System.println. i just don't understand why is ignoring my equality. If someone could explain me what im doing wrong. thank.