116 Part II: Writing Your Own Java Programs (Paypal web hosting)
116 Part II: Writing Your Own Java Programs Listing 5-5 (continued) out.println( You re in. ); } else { out.println( Incorrect password ); } } else { out.println( Unknown user ); } } } Figure 5-6 shows several runs of the code in Listing 5-5. The main idea is that to log on, you have to pass two tests. (In other words, two conditions must be true.) The first condition tests for a valid username; the second condition tests for the correct password. If you pass the first test (the username test), you march right into another ifstatement that performs a second test (the password test). If you fail the first test, you never make it to the second test. The overall plan is shown in Figure 5-7. Figure 5-6: Authenticating a user. The code in Listing 5-5 does a good job with nested ifstatements, but it does a terrible job with real-world user authentication. First of all, never show a password in plain view (without asterisks to masquerade the password). Second, don t handle passwords without encrypting them. Third, don t tell the malicious user which of the two words (the username or the password) was entered incorrectly. Fourth . . . well I could go on and on. The code in Listing 5-5 just isn t meant to illustrate good username/password practices. Choosing among Many Alternatives (Java switch Statements) I m the first to admit that I hate making decisions. If things go wrong, I would rather have the problem be someone else s fault. Writing the previous sections (on making decisions with Java s ifstatement) knocked the stuffing right out of me. That s why my mind boggles as I begin this section on choosing among many alternatives. What a relief it is to have that confession out of the way!
Do you have a godaddy domain name? If you do, you have found the right web hosting provider for you.Our Godaddy Web Hosting packages are the best match to well known, affordable godaddy domain names.