假設其中的JDBCUser類是一個任意User類
這樣
public void login()
throws ACLException
{
/* get JDBC User Class */
if (user != null)
{
logout();
}
{
// if session time out
JDBCUserFactory uf = new JDBCUserFactory();
if ( (this
{
throw new ACLException(
}
JDBCUser user = (JDBCUser) uf
this
this
user
this
this
}
}
Login的時候
public void logout()
throws SQLException
{
if (this
{
return;
}
Vector activeSessions = (Vector) this
if (activeSessions != null)
{
activeSessions
application
}
java
while (e
{
String s = (String)e
this
}
this
this
}
這兩個函數位於一個HttpSessionManager類中
下面來看看JSP裡面怎麼用
假設一個登錄用的表單被提交到doLogin
<%
HttpSessionManager hsm = new HttpSessionManager(application
try
{
hsm
}
catch ( UserNotFoundException e)
{
response
return;
}
catch ( InvalidPasswordException e
{
response
return;
}
catch ( Exception e
{
%> Error:<%=e
Press <a href=
<% return;
}
response
%>
[
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/20685.html