Reputation: 437
We have been attempting to create user logins on our JSP web app using JDBC realms, following this tutorial. We have followed the tutorial like for like, but it just won't work! Basically, the login form doesn't accept any credentials, however we don't know if it's due to a communication issue, or that there is no communication!
Here is some of our code, which hopefully is enough to show what went wrong!
Our relevant database tables:
Our web.xml file:
<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>
<jsp-config>
<jsp-property-group>
<description>JSP configuration for Bandy</description>
<url-pattern>/index.jsp</url-pattern>
<url-pattern>/WEB-INF/view/*</url-pattern>
<include-prelude>/WEB-INF/jspf/menu.jspf</include-prelude>
<include-coda>/WEB-INF/jspf/seal.jspf</include-coda>
</jsp-property-group>
</jsp-config>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>bandyRealm</realm-name>
<form-login-config>
<form-login-page>/login.jsp</form-login-page>
<form-error-page>/error.jsp</form-error-page>
</form-login-config>
</login-config>
<security-constraint>
<web-resource-collection>
<web-resource-name>Bandy user</web-resource-name>
<url-pattern>/protected/protected.jsp</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>ADMIN</role-name>
<role-name>USER</role-name>
</auth-constraint>
</security-constraint>
Our glassfish-web.xml file:
<glassfish-web-app error-url="">
<class-loader delegate="true"/>
<jsp-config>
<property name="keepgenerated" value="true">
<description>Keep a copy of the generated servlet class' java code.</description>
</property>
</jsp-config>
<security-role-mapping>
<role-name>ADMIN</role-name>
<group-name>ADMIN</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>USER</role-name>
<group-name>USER</group-name>
</security-role-mapping>
Our jdbc realm settings:
Our project structure:
Upvotes: 0
Views: 1420
Reputation: 545
Your declared realm in web.xml (bandyRealm) doesn't exist. Try setting it to what you named in glassfish, namely "jdbc-realm"
Upvotes: 1