1
I have the following situation.
I get a string that is in the application’s localStorage in a javascript variable.
<script>
var sendForm = localStorage.getItem('f');
</script>
This same string I pass to a java variable to perform the proper procedures I will need.
<%
String id_formulario = "";
id_formulario = "<script>document.write(sendForm)</script>";
%>
To perform tests I show this string with a
<%
out.print(id_formulario);
%>
And that’s all right! it is the exact string that was in localStorage, but when I try to compare it with any string EQUAL java does not recognize that they are equal and simply ignore.
<%
if(id_formulario.equals("QUALQUERVALOR")){
out.print("É igual!!!");
}
%>
Why is this happening? I’ve tried everything and I can’t solve this problem at all!!
I’ve tried equalsIgnoreCase, ==, ==, equals but all of this goes as if it’s not the same string I took from localStorage
– Junior
By showing the length() of the received value and what I expected gave a difference that ended up visualizing the problem. The value I received had 41 characters while the one I expected had 22.
– Junior
when you have the variable typed
id_formulario
alone, for example, he’s the way you hoped?– R.Santos