GlassFish が複数の http セッションを作成するレルム認証について質問があります。これが例です
Web.xml:
<security-constraint>
<web-resource-collection>
<web-resource-name>AllPages</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>user</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>FileRealm</realm-name>
</login-config>
<security-constraint>
グラスフィッシュ-web.xml:
<security-role-mapping>
<role-name>user</role-name>
<group-name>users</group-name>
</security-role-mapping>
login.jsp:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Welcome Page</title>
</head>
<body>
<p>You have successfully logged into the application.</p>
<a href="./home.jsp">go to home</a>
</body>
</html>
セッションリスナー:
@WebListener public class SessionListener は HttpSessionListener を実装します {
public void sessionCreated(HttpSessionEvent arg0) {
System.out.println("セッション作成 ID:"+arg0.getSession().getId());
}public void sessionDestroyed(HttpSessionEvent arg0) {
System.out.println("Session destroyed id:"+arg0.getSession().getId());
}
}
認証すると、glassfish は新しいセッションを作成します。
情報: セッションが作成されました id:29c5d904db0e40b9cfbdac40aa5e
「ホームに移動」リンクをクリックするか、ページを更新すると、glassfish は別の http セッションを作成します。
情報: セッションが作成されました id:2a67270137e38c150bf3690e2e46
また、glassfish が最初に作成されたセッションを破棄しないことにも気付きました。
ご協力いただきありがとうございます