You need to use BASIC
authentication. You need to use JAAS
for the same.
This tutorial provides FORM
based authentication. but as you want BASIC
authentication, you need to
<login-config>
<auth-method>BASIC</auth-method>
</login-config>
You can retrieve the user principal as follows
request.getUserPrincipal().getName().toString();