The easiest way is to use the authentication mechanisms provided by the container, and basic authentication is the easiest. Here is an example showing how to do this in your application. However, the main caveat with this approach is that your credentials pass through the network in clear text. Because of this, you DEFINITELY want to implement SSL on your application server to encrypt data on the go.
source share