The following is the code that I am executing through Tomcat and is not giving me the desired result:
Code:
---------
<%
String myvar = request.getParameter("var1");
boolean first = false;
if (myvar == null) {
first = true;
} else {
if (myvar == "compareme") out.println("string matches"); else out.println("string MISMATCH");
}
%>
If you enter input as "compareme", I should say "MATCH",
else "MISMATCH"
<% if (! first) { %>
Input was <%= myvar %>
<% } %>
---------
You will notice that even though the correct string "compareme" is submitted in the form, the string comparison still fails. I have tried appending .toString() and .trim() to myvar but that has not helped either.
I am obviously missing something very basic in JSP. Please help
Read More...
No comments:
Post a Comment