How do I use a JDBC Realm with Tomcat and MySQL?
Author: Deron Eriksson
Description: This Tomcat tutorial describes how to configure Tomcat to use a JDBC Realm with MySQL for container-managed security.
Tutorial created using: Windows XP || JDK 1.5.0_09 || Eclipse Web Tools Platform 2.0 (Eclipse 3.3.0) || Tomcat 5.5.20


Page: < 1 2 3

(Continued from page 2)

Next, I'll start the 'tomcat-demo' project in TomcatSW in EclipseSW.

Tomcat started in Eclipse

In a browser, I'll attempt to hit the test servletW via http://localhost:8080/tomcat-demo/test. Since we're using Basic authentication and this is a protected resource, a pop-up window appears asking for a name and password.

Basic authentication required to access test servlet

I'll try entering an invalid name and password. This doesn't work.

Entering invalid name and password fails

I'll enter a good name and password. In our tomcat_realm databaseW, we created a user called 'deron' with a password of 'deronpass'. The 'deron' user has the roles of 'dude' and 'manager'. Since our web.xmlW specifies that a user with the role of 'dude' is required, 'deron'/'deronpass' should work.

Entering valid name and password

The user name and password is authenticated, and we are granted access to the test servlet.

User is authenticated and granted access to the protected resource

In this tutorial, we've seen that it is quite straightforward to set up Tomcat with a JDBCW realm with MySQLW in order to perform container-based authentication.

Page: < 1 2 3