I was following this tutorial to create form-based authentication in for my jboss java EE 6 application.
However it has no code for the login servlet. After searching other resources I found that the login servlet code is not mentioned anywhere.
Where can I find the code for the login servlet? Maybe its very basic, but I am new to Java and I can't write it myself.
The tutorial doesn't have servlet code because the security is provided by the container itself and container security is configured using the deployment descriptor.
You may read this article for further information and decide whether you use the container security or a custom implementation.
At Stormpath, we have a ready-to-use login Servlet that you could use. The only caveat is that it requires Servlet 3.0 or later and it is coupled to our own User Management service.
Our Login Servlet will automate all user registration, login, authentication and authorization workloads.
Take a look at this one page long quickstart: https://docs.stormpath.com/java/servlet-plugin/quickstart.html. It will describe the few steps that you need to carry out to integrate it into your app.
BTW, the Servlet Plugin is completely open source; the code is here in case you want to take a look at it.