/    Sign up×
Community /Pin to ProfileBookmark

why isn’t the if statement working. It goes else part even if the username and password is in there.

String vusername = request.getParameter(“username”);
String vpassword = request.getParameter(“password”);

if((vusername != null) && (vusername.equals(“”))) {
response.sendRedirect(“http://localhost:8080/myHW3/CatalogServlet“);
} else {
out.println(“<html>”);
out.println(“<head>”);
out.println(“<title>Login</title>”);
out.println(“</head>”);
out.println(“<BODY BGCOLOR=357EC7>”);
out.println(“<form method=POST>”);
out.println(“Invalid username/password”);
out.println(“<p><A style=color:black HREF=RegistrationServlet>Click here to return to Login Page</A></p>”);
out.println(“</form>”);
out.println(“</BODY></HTML>”);

to post a comment
Java

3 Comments(s)

Copy linkTweet thisAlerts:
@Khalid_AliNov 07.2011 — I think u want to say when [color=red]![/color]vusername.equals("")

instead, which would mean you are checking for

when user is not null and user is not empty
Copy linkTweet thisAlerts:
@selinaNov 14.2011 — For what purpose you are using - vusername.equals((""))??

Try if block without using vusername.equals((""))
Copy linkTweet thisAlerts:
@newbee4126authorNov 14.2011 — it was actually a syntax error in the HTML...thanks!
×

Success!

Help @newbee4126 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.27,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...