tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Fox <cs...@extra.net>
Subject Re: getParameter not comparing to Strings
Date Sat, 20 May 2000 07:05:41 GMT
Don't worry there are other old C programmer's here too ya know
;)

Mark Williamson wrote:

> This is how you can tell I am an old C programmer
> some old habits die hard.......
> sorry about that.
>
> -----Original Message-----
> From: Edward W. Rouse [mailto:erouse@vei.net]
> Sent: 18 May 2000 18:14
> To: tomcat-user@jakarta.apache.org
> Subject: Re: getParameter not comparing to Strings
>
> You would only use compareTo if you also would need to no if one string is
> 'greater than' or 'less than' (comes before or after) another string. If you
> are
> only interested in equal or not equal then use the equals() method.
> Ed.
>
> Richard McKinley wrote:
>
> > So I would write?:
> >
> > if (request.getParameter("someparameter").compareTo(myrequest) == 0) { }
> >
> > -----Original Message-----
> > From: Mark Williamson [mailto:Mark.Williamson@Appropria.com]
> > Sent: Thursday, May 18, 2000 10:19 AM
> > To: 'tomcat-user@jakarta.apache.org'
> > Subject: RE: getParameter not comparing to Strings
> >
> > You have to use compareTo to compare
> > two strings. == only works on "" for some
> > reason.
> >
> > mark
> >
> > -----Original Message-----
> > From: Richard McKinley [mailto:rrm@randtech.com]
> > Sent: 18 May 2000 17:48
> > To: 'tomcat-user@jakarta.apache.org'
> > Subject: getParameter not comparing to Strings
> >
> > 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>
> >
> > --------------------------------------------------------------------------
> > To unsubscribe, email: tomcat-user-unsubscribe@jakarta.apache.org
> > For additional commmands, email: tomcat-user-help@jakarta.apache.org
> >
> > --------------------------------------------------------------------------
> > To unsubscribe, email: tomcat-user-unsubscribe@jakarta.apache.org
> > For additional commmands, email: tomcat-user-help@jakarta.apache.org
> >
> > --------------------------------------------------------------------------
> > To unsubscribe, email: tomcat-user-unsubscribe@jakarta.apache.org
> > For additional commmands, email: tomcat-user-help@jakarta.apache.org
>
> --------------------------------------------------------------------------
> To unsubscribe, email: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commmands, email: tomcat-user-help@jakarta.apache.org
>
> --------------------------------------------------------------------------
> To unsubscribe, email: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commmands, email: tomcat-user-help@jakarta.apache.org


Mime
View raw message