This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes login (upper and lower letter case) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "login (upper and lower letter case)" Watch "login (upper and lower letter case)" New topic
Author

login (upper and lower letter case)

Li Jenny
Ranch Hand

Joined: Apr 19, 2010
Posts: 57
how can i conside the upper letter and lower letter case when the user use the user id to login.
it is because when the user table have the user id is 'AM'
when the user type lower letter 'am' that i can login to the system.

how can i match the letter that exactly same as the database then let user login.


if(am==AM),then can't login
if(Am==AM),then can't login.

if(AM==AM),then login
pete reisinger
Ranch Hand

Joined: Dec 30, 2009
Posts: 46
Hi,
I suppose that user name is string.
It means that String is an object, not primitive (primitives start with lower case letter - int, boolean etc., classes start with upper case letter - String, Integer etc.)
"==" is used to compare primitive values, not objects.
So check the String api and you'll find out the right way to compare
two strings (of objects) plus other very useful methods that can help you.
Nicola Garofalo
Ranch Hand

Joined: Apr 10, 2010
Posts: 308
Suppose dbuser is the String you get from your database and user the String the user types to log in



tests whether dbuser and user have the same value or not,

if dbuser = "AM"

and user = "am" (or "Am" or "aM")

dbuser.equals(user) returns false

but if user = "AM" it returns true



Bye,
Nicola
Li Jenny
Ranch Hand

Joined: Apr 19, 2010
Posts: 57
thanks.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: login (upper and lower letter case)
 
Similar Threads
Strange behaviour of jsp:include
Strings
Very New To Java Question Help Please!
Scanner string parameters
Java class query