How do i programmatically authenticate to the servlet container usin Tomcat? I was unable to find the appropriate API call to do so. The reason i need this is because the web app that i have has a self registration feature (like most other web apps). Currently without making the API call, i first take the username/password from the user. Then i make the appropriate entries to the user & user role table (Am using JDBCRealm), After which a client side redirect is sent to access a protected page. The container, intercepts the request and forwards to the login screen (am using form based authentication). The user enters their credentials and gets logged into the app. As you can see that during registration the user needs to first register, and then login. This is big inconvenience and a usability issue. To avoid this i would like the user to register after which i want to programmatically log the user to the servlet container, thus avoiding the user to enter redundant info twice.