tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Richard McKinley <...@randtech.com>
Subject getParameter not comparing to Strings
Date Thu, 18 May 2000 16:48:10 GMT
When I use request.getParameter() it returns a string that look exactly like
the string to which I want to compare it.  Alas, the result of the compare
is that they are not the same.  Attached is a small .jsp that shows the
problem.  What am I doing wrong?


***********start getparameter.jsp**************
<%
String myrequest = "fish";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<!-- The expression tags interpolate script variables into the HTML -->

<title>getrequest</title>
</head>

<body bgcolor=white>

<h1>
  The result of request.getParameter("someparameter") = 
  <%= request.getParameter("someparameter")%>
</h1>
<a href="getparameter.jsp?someparameter=<%= myrequest%>">test</a><br>
<%
if (request.getParameter("someparameter") == myrequest) {
  out.print(request.getParameter("someparameter") + "==" + myrequest +
"<br>");
} else {
  out.print(request.getParameter("someparameter") + "!=" + myrequest +
"<br>");
}
%>
</body>

Mime
View raw message