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

Archived Comments

1. Wow, that's what I was exploring for, what a data! existing here at this web site,
thanks adm

View Tutorial          By: what is list of forex companies in india at 2017-08-31 11:53:27

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

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

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

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

6. After edit tomcat-user file and restart sevice login but not to an application ..just show belo
View Tutorial          By: Rajesh Perumal at 2013-01-08 06:29:21

7. Hi, these are the lines i added after i downloaded the binary distribution.. when i entered this use
View Tutorial          By: sandeep,p at 2012-11-22 10:17:07

8. <tomcat-users>
<role rolename="manager-script"/>
<user us

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

Most Viewed Articles (in Java )

Latest Articles (in Java)

Comment on this tutorial