cos mi nie działa. napisałem czesc projektu tylko mam problem....
jesli loguje sie przy uzyciu danych zdefiniowanych w conf/tomcat-users to wszystko ładnie działa. jednak chciałem żeby urzytkwonicy byli zarejestrowani w mojej bazie. dlatego w Netbeans w meta-inf/context.xml wpisałem coś takiego:
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/jdFaktura">
<Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"
driverName="org.gjt.mm.mysql.Driver"
connectionURL="jdbc:mysql://localhost:3306/jdFaktura5"
connectionName="root" connectionPassword="root"
userTable="users" userNameCol="user_name" userCredCol="user_pass"
userRoleTable="user_roles" roleNameCol="role_name"/>
</Context>
korzystałem z informacji z tej strony:
http://tomcat.apache.org/tomcat-4.1-doc/realm-howto.html
tabele:
create table users (
user_name varchar(15) not null primary key,
user_pass varchar(15) not null
);
create table user_roles (
user_name varchar(15) not null,
role_name varchar(15) not null,
primary key (user_name, role_name)
);
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<login-config>
<auth-method>FORM</auth-method>
<form-login-config>
<form-login-page>/logowanie.jsp</form-login-page>
<form-error-page>/login_error.jsp</form-error-page>
</form-login-config>
</login-config>
<!--atoryzacja przed dostepem do folderu autoryzacja-->
<security-constraint>
<web-resource-collection>
<web-resource-name>mojeKonto</web-resource-name>
<url-pattern>/mojeKonto.jsp</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>admin</role-name>
</auth-constraint>
</security-constraint>
<!--atoryzacja przed dostepem do folderu autoryzacja-->
<!--uzytkownicy-->
<security-role>
<role-name>admin</role-name>
</security-role>
<security-role>
<role-name>user</role-name>
</security-role>
<!--uzytkownicy-->
<!--index-->
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<!--index-->
</web-app>
projekt kompiluje się ...
dane w tableli - uzytkownik admin, haslo admin, rola admin