This is Basic Authentication supported by Servlet technology. This is how you define basic authentication for web resources in web.xml.
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>default</realm-name>
</login-config>
Please find here a complete example:
<?xml version='1.0' encoding='UTF-8'?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<web-app>
<welcome-file-list>
<welcome-file>welcome.jsp</welcome-file>
</welcome-file-list>
<security-constraint>
<web-resource-collection>
<web-resource-name>Success</web-resource-name>
<url-pattern>/secured/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>secured</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>default</realm-name>
</login-config>
<security-role>
<role-name>secured</role-name>
</security-role>
</web-app>
Please read the below link for more understanding on several authentication mechanisms supported by Servlet technology:
Standard form authentification Java servlets