Creating Users and Passwords with Tomcat using tomcat-users.xml

By: Emiley J.  

A very easy method of authenticating users with Tomcat involves creating usernames, passwords, and roles in the tomcat-users.xml file. This file is stored in <Tomcat-installation-directory>/conf.

Everyone is familiar with usernames and passwords, but what are roles? Roles are logical ways to describe groups of users who have similar responsibilities, such as manager or databaseAdmin. Example below shows a tomcat-users.xml file that creates two roles and two users with two aptly named XML elements: role and user.

The tomcat-users XML file
<?xml version='1.0' encoding='utf-8'?>

  <role rolename="dbadmin"/>
  <role rolename="manager"/>
  <user username="BruceP" password="bwperry" roles="dbadmin,manager"/>
  <user username="JillH" password="jhayward" roles="manager"/>

In above example, the user BruceP is associated with two roles (dbadmin and manager), while user JillH is associated only with the manager role. Tomcat uses this file when authenticating users with BASIC and form-based authentication

Most Viewed Articles (in Java )

Latest Articles (in Java)

Comment on this tutorial

Subscribe to Tutorials

Related Tutorials

Archived Comments

1. <tomcat-users>
<role rolename=&q

View Tutorial          By: nc30 at 2012-04-18 10:13:10

2. Hi, these are the lines i added after i downloaded
View Tutorial          By: sandeep,p at 2012-11-22 10:17:07

3. After edit tomcat-user file and restart sevice ..i
View Tutorial          By: Rajesh Perumal at 2013-01-08 06:29:21

4. thank u.....
View Tutorial          By: DiptaRanjan at 2013-02-02 14:56:45

5. thanks alot.
View Tutorial          By: ZolTech at 2013-06-01 17:57:40

6. Servicerzo
View Tutorial          By: Servicepke at 2017-06-29 06:10:11

7. autohitsrn
View Tutorial          By: autohiteav at 2017-07-12 08:26:54

8. Wow, that's what I was exploring for, what a data!
View Tutorial          By: what is list of forex companies in india at 2017-08-31 11:53:27