traixuhan
|
Posted: 09/10/2004, 2:07 AM |
|
I do my project Quesion bank, you can help me. I don't have log out jsp
|
|
|
Anton Hinxman
|
Posted: 09/20/2004, 2:06 AM |
|
I do not understand your question but think that you need a logout function to be like:
(Note: I have a datetime lastedit column in my user table and reset it to null)
/* Logout feature used in Default jsp
*/
public void logoutUser(com.codecharge.components.Page targetPage) {
if( Utils.getUserLogin(targetPage) != null ) {
com.codecharge.db.JDBCConnection conn = com.codecharge.db.JDBCConnectionFactory.getJDBCConnection("YOURDBCONN");
try {
if(conn instanceof com.codecharge.db.JDBCConnection) {
String sql = "Update users SET lastedit = null WHERE userlogin = "+
conn.toSql(Utils.getUserLogin(targetPage),JDBCConnection.TEXT);
CCLogger.getInstance().info("Logging off via: "+ sql);
conn.executeUpdate(sql);
} else {
CCLogger.getInstance().error("Unable to logout due to bad connection");
}
} catch (Exception ex) {
com.codecharge.util.CCLogger.getInstance().error(".logout has error:"+ ex.getMessage());
ex.printStackTrace();
}
if(conn instanceof com.codecharge.db.JDBCConnection) {
CCLogger.getInstance().info("Proper logout close of connection");
conn.closeConnection();
}
// SessionStorage.getInstance(targetPage.getRequest()).removeAttribute("LogOffUser");
} else {
CCLogger.getInstance().info("Unable to find user name for session (not logged in) "+ Utils.getUserLogin(targetPage));
}
com.codecharge.util.Authenticator auth = com.codecharge.util.AuthenticatorFactory.getAuthenticator( targetPage.getRequest() );
auth.setRequest( targetPage.getRequest() );
auth.setResponse( targetPage.getResponse() );
auth.invalidate();
}
Regards
Anton
|
|
|
|