最近、Java EE Webプログラミングについて学び始めました。Netbeans 8.2とGlashfish 4.1.1でいくつかのJSPページを使用して認証トピックを作成しました私は、次のされたチュートリアルです:HTTPステータスの取得403 - Glassfish 4.1.1へのログイン後に禁止
https://www.youtube.com/watch?v=GXnwtR1lT3w
私は段階的に従うが、私は自分のユーザー名とパスワードサーバを使用してログインするときだけ私にHTTPステータス403を送っていた - 禁断のエラー、私は、ファイル内のユーザーを設定しました'AppAdmin'をグループリストとして使用して、server-configのrealm securityセクションに移動します。
これは私のlogin.jspです:
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Login</title>
</head>
<body>
<h1>Login Page</h1>
<p>Please enter your username and password to login.</p>
<form action="j_security_check" method="POST">
<table border="0">
<tbody>
<tr>
<td>Username:</td>
<td><input type="text" name="j_username" value="" /></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="j_password" value="" /></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Login Now" /></td>
</tr>
</tbody>
</table>
</form>
</body>
</html>
これは私のweb.xmlです:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<security-constraint>
<display-name>Admin Pages</display-name>
<web-resource-collection>
<web-resource-name>Administrative Pages</web-resource-name>
<description/>
<url-pattern>/admin/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<description/>
<role-name>admin</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>file</realm-name>
<form-login-config>
<form-login-page>/login.jsp</form-login-page>
<form-error-page>/login_error.jsp</form-error-page>
</form-login-config>
</login-config>
<security-role>
<description>Administrators</description>
<role-name>admin</role-name>
</security-role>
<security-role>
<description>Common Users</description>
<role-name>user</role-name>
</security-role>
</web-app>
これは私のglassfish-web.xmlの
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app error-url="">
<security-role-mapping>
<role-name>admin</role-name>
<principal-name>admin</principal-name>
<group-name>AppAdmin</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>user</role-name>
<principal-name>user</principal-name>
<group-name>AppUser</group-name>
</security-role-mapping>
<jsp-config>
<property name="keepgenerated" value="true">
<description>Keep a copy of the generated servlet class' java code.</description>
</property>
</jsp-config>
</glassfish-web-app>
である私は運でいくつかのフォーラムで読んでいくつかのことを試してみました。この部分にstuckedです。
ご協力いただきありがとうございます。