• Post Reply Bookmark Topic Watch Topic
  • New Topic

User Site logon  RSS feed

 
Kameswari Jyosyula
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am trying to direct the users to different pages depending on the password they enter , i.e. if the password is say pwd1 goto page1 and if it is pwd2 goto page2.
I am including the code i have written The class Usercredentials had the method getPassword - which returns the password).
<jsp:useBean id="sessionManager" class="SessionManager"
scope="application" />
<jsp:useBean id="credentials" class="UserCredentials"
scope="session" />
<jsp:setProperty name="credentials" property="*"/>
<%! String nextPage; %>
<%
if (sessionManager.alreadyLoggedIn(credentials)) {
nextPage = "DuplicateLogin2.jsp";
}
else {
if (sessionManager.login(credentials)) {
credentials.setSessionId(session.getId());
sessionManager.initiateSessionLogging(credentials);
if(credentials.getPassword()="mypassword")

nextPage = "page1.jsp";
else
nextPage = "page2.jsp";
}
else {
nextPage = "LoginFailure2.jsp";
}
}
%>
<jsp:forward page="<%= nextPage %>" />
<%@ page errorPage="Exception.jsp" %>
When i try this i get the error "Invalid left hand assignment" at
if(credentials.getPassword()="mypassword")
So how do i do it? Plz let me know
TIA

 
Trevor Dunn
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When i try this i get the error "Invalid left hand assignment" at
if(credentials.getPassword()="mypassword")

You are trying to assign the value returned by credentials.getPassword() to "mypassword" in an if statement. It should read

This is assuming that the method returns a string
Trevor
 
Kameswari Jyosyula
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oops!That was a silly mistake on my part.
Thank you for pointing that out.
Kameswari
Originally posted by Trevor Dunn:
[B]
This is assuming that the method returns a string
Trevor
[/B]

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!