Sequrity on a context or folder
How to create a login on a folder or context like this:

Find the tomcat-users.xml, its located in your %TomcatHome%/config folder.
<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<role rolename="friend"/>
<user username="Scott" password="Tiger" roles="friend"/>
</tomcat-users>
Add your users here and roles here.
Next step is to alter the web.xml in the WEB-INF folder.
.......
<web-app>
........
<security-constraint>
<web-resource-collection>
<web-resource-name>Entire folder</web-resource-name>
<url-pattern>/folder/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>friend</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>Your Realm Name</realm-name>
</login-config>
<security-role>
<description>The role that is required to log in to
the Manager Application</description>
<role-name>friend</role-name>
</security-role>
</web-app>
Here you have password protected the /folder/. Every user in the friend role can logon to your /folder/.
Every sub-folders of this folder is protected.