: getParameter is NOT a string?
Brett Bergquist wrote:
> Actually the test that you want is:
>
> if (user.compareTo("admin") == 0) {
> ...
> }
And how is this any different from using "if (user.equals("admin"))"?
--
Hi Charles,
> A few notes:
>
> 1) java.lang.Comparable is new in Java2. It's not there
>if you are running w/Java 1.1 (OK with Tomcat 3.x).
>
> 2) compareTo(), for Strings does a *lexical* comparison.
>Semantically, this code wants to know that the user
>is "admin", not that the u
Miles Daffin wrote:
>
> > Brett Bergquist wrote:
> > > Actually the test that you want is:
> > >
> > > if (user.compareTo("admin") == 0) {
> > > ...
> > > }
> >
> > And how is this any different from using
> > "if (user.equals("admin"))"?
> ...
> 'compareTo(Object
> Brett Bergquist wrote:
> > Actually the test that you want is:
> >
> > if (user.compareTo("admin") == 0) {
> > ...
> > }
>
> And how is this any different from using "if (user.equals("admin"))"?
The method 'compareTo(Object o)' is specified in java.lang.Comparabl
> if (user == "admin")
> {
> }
>
> then it doesnt go into this condition, but goes into the ELSE instead!!!
>
> Why is this?
You need to do some basic Java study.
The conditional test above actually asks this:
If
the explicit String type object reference 'user' points to the same
Note for newer Java programmers:
For this example, they are equivalent. But String.compareTo() returns an int
and can be used, like the C function memcmp(), to test all of >, ==, and <.
In addition to String.equals(), do not overlook String.equalsIngoreCase(),
should you need a case-insensit
Brett Bergquist wrote:
> Actually the test that you want is:
>
> if (user.compareTo("admin") == 0) {
> ...
> }
And how is this any different from using "if (user.equals("admin"))"?
--
Kurt Pruenner - Haendelstrasse 17, 4020 Linz, Austria | Briareos at Olymp BBS:
Actually the test that you want is:
if (user.compareTo("admin") == 0) {
...
}
-Original Message-
From: Cliff Rowley [mailto:[EMAIL PROTECTED]]
Sent: Saturday, November 18, 2000 7:35 AM
To: [EMAIL PROTECTED]
Subject: RE: getParameter is NO
Cliff Rowley
The reader this message encounters not failing to understand is cursed.
- while ( !asleep ) { code(); }
-Original Message-
From: Winnie Cheung [mailto:[EMAIL PROTECTED]]
Sent: 18 November 2000 05:55
To: [EMAIL PROTECTED]
Subject: getParameter is NOT a string?
Hi I am getting
ge-
From: Winnie Cheung [mailto:[EMAIL PROTECTED]]
Sent: Saturday, November 18, 2000 12:55 AM
To: [EMAIL PROTECTED]
Subject: getParameter is NOT a string?
Hi I am getting a form field (POSTed form) as
String user = (String) request.getParameter("user");
When I out.print this, it
Hi I am getting a form field (POSTed form) as
String user = (String) request.getParameter("user");
When I out.print this, it writes the correct value, but when i COMPARE this
in an IF condition, it doesnt work. Any reason why? For example, lets say
the "user" textfield in my form is "admin".
11 matches
Mail list logo