we are migrating code from JDK6/JBoss 5.1 to JDK8/JBoss 7.
In existing codebase, empty string validation was incorrectly written as str!="". However this code is working fine in JBoss 5.1/JDK6. But when trying to run the same code base in JDK8/JBoss 7, the empty string validation is breaking. I fixed this by using str.isEmpty() method. But why it is working differently in JBoss 5.1/JDK6 and JDK8/JBoss 7. The value for string object is retrieved from request.getParameter("<>") statement.
Code Snippet:
String tmpFlag= request.getParameter("Flag");
if( tmpFlag != null && tmpFlag !="" ){
//some logic
}
request.getParameter("Flag"); --> returns "" String in both cases.