dcsimg
error 500
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Gaurav_Bhargava
Posted On:   Monday, April 2, 2001 12:51 PM

Hi there I am using two beans through a jsp page which go to the database and retieve information about the user, now the problem i am facing is my server responds by saying it cannot create bean of class com.LoginManager... The code for jsp page is <%! String nextPage; %> <% if(loginManager.login(credentials)) { nextPage = "MainMenu.jsp"; } else if(loginManager.alreadyLoggedIn(credentials)) { nextPage = "Duplicatelogin.jsp"; } else { nextPage = "LoginFailure.jsp"; } %> <%= nextPage %>"/> The code for LoginManager is    More>>

Hi there
I am using two beans through a jsp page which go to the database and retieve information about the user, now the problem i am facing is my server responds by saying it cannot create bean of class com.LoginManager...
The code for jsp page is









<%! String nextPage; %>

<% if(loginManager.login(credentials)) {
nextPage = "MainMenu.jsp";
}
else if(loginManager.alreadyLoggedIn(credentials)) {
nextPage = "Duplicatelogin.jsp";
}
else {
nextPage = "LoginFailure.jsp";
}
%>
<%= nextPage %>"/>


The code for LoginManager is




package com;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Date;
import java.util.Hashtable;
import javaservlets.jdbc.*;
import java.io.*;


public class LoginManager implements Serializable {
private Hashtable currentLogins;
private ConnectionPool connectionpool;

private static final String SELECT_PASSWORD =
"SELECT Password from LoginInfo WHERE UserID = ";

private static final String QUOTE = "'";
private class LoginProfile extends UserCredentials {
boolean isLoggedIn = false;

public LoginProfile(UserCredentials credentials) {
setUser(credentials.getUser());
setpassword(credentials.getPassword());
setSessionId(credentials.getsessionId());
isLoggedIn = false;

}
}

public LoginManager() throws Exception {
connectionpool = new ConnectionPool();
connectionpool.initialize();
currentLogins = new Hashtable();
}

public boolean alreadyLoggedIn(UserCredentials credentials) {
boolean loggedIn = false;
String user = credentials.getUser();
if(currentLogins.containsKey(user)) {
LoginProfile aProfile = (LoginProfile)currentLogins.get(user);
loggedIn = aProfile.isLoggedIn;
}
return loggedIn;
}

public boolean login(UserCredentials credentials) throws SQLException {
if(alreadyLoggedIn(credentials)) {
return false;
}
LoginProfile profile = new LoginProfile(credentials);
Connection conn = connectionpool.getConnection();
Statement qs = conn.createStatement();
ResultSet rs = qs.executeQuery(SELECT_PASSWORD + QUOTE + credentials.getUser() + QUOTE);
while (rs.next()) {
if(rs.getString(1).equals(credentials.getPassword())) {
profile.isLoggedIn = true;
currentLogins.put(credentials.getUser(),profile);
break;
}
}
return profile.isLoggedIn;

}

}

and last but not the least the code for UserCredentials.java is

package com;


public class UserCredentials {
private String user;
private String password;
private String sessionId;

public UserCredentials() {
user = "";
password = "";
sessionId = "";
}
public String getUser() {
System.out.println(user);
return user;
}

public void setUser(String user) {
this.user = user;

}

public String getPassword() {
return password;

}

public void setpassword(String password) {
this.password = password;

}

public String getsessionId() {
return sessionId;

}

public void setSessionId(String sessionId) {
this.sessionId = sessionId;

}


}

I know this is a big one....but pls help...i am stuch badly here...
Thank you
Gaurav Bhargava

   <<Less
About | Sitemap | Contact