> Er det muligt? Og så så fald hvordan? Takker pfh.
Fand ud af det. Men det virker ikke: Jeg har postete en post i en uddenlands
NG, men der er ingen svar så i får den lige på engelsk. Håber der er ok:
Hi
I have tried all night to make tomcat authenticate a user trough mysql using
forms_auth
But I cant get it to connect to my mysql database. I have followed these
tutorials:
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/realm-howto.html#JDBCRealm
http://www.onjava.com/pub/a/onjava/2002/06/12/form.html
i have copied the jar file with the mysql JDBC driver into /server/lib
I have set up the server.xml file with this:
----------------------------------------
<Realm className="org.apache.catalina.realm.JDBCRealm"
debug="99"
driverName="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://192.168.0.1:3306/authority?user=xxxx;password=xx
xx"
userTable="users"
userNameCol="user_name"
userCredCol="user_pass"
userRoleTable="user_roles"
roleNameCol="role_name"/>
I have created the tables and filled them with data. I have assured that i
can connect to the mysql db from my test machine. I have set up the web.xml
with the what you see in the bottom of this post:
The problem is that when I press the submit buttom on my login page it
immidatly redirects my to the errorpage. I can see with a port monitor that
no calss to the database have been tried. So i presume that the problem is
in the server.xml file...but I cant figure what. anything that usally goes
wrong?
-------- WEB.XML -------------
<web-app version="2.4" xmlns="
http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Formauth</display-name>
<servlet>
<display-name>formauth</display-name>
<servlet-name>formauth</servlet-name>
<jsp-file>/index.jsp</jsp-file>
</servlet>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<security-constraint>
<web-resource-collection>
<web-resource-name>Protected Area</web-resource-name>
<url-pattern>/*</url-pattern>
<http-method>PUT</http-method>
<http-method>DELETE</http-method>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>staffmember</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<!--<realm-name>default</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-role>
<role-name>staffmember</role-name>
</security-role>
</web-app>