Java, Software Development, Tomcat

Java Web Application BASIC Authentication in Tomcat

This post demonstrates how to use Basic Authentication in a web application in Java using Tomcat.


  • Tomcat 8.5.37
  • Open JDK 1.8.0_192

Users and Roles

Update conf/tomcat-users.xml with the following roles and users.

Update web.xml

Then, modify web.xml with the following security-constraint and login-config elements.

Here we wanted to restrict the whole application.


The CONFIDENTIAL value for transport-guarantee element forces the authentication process to be done in SSL.



You Might Also Like