Here is the part defining security for a resource in the web.xml and declaration of form based authentication.
<security-constraint>
<web-resource-collection>
<web-resource-name>profile</web-resource-name>
<url-pattern>/myProfile</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>member</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<form-login-config>
<form-login-page>/signin.jsp</form-login-page>
<form-error-page>/signin_error.jsp</form-error-page>
</form-login-config>
</login-config>
<security-role><role-name>member</role-name></security-role>
And here is the realm definition in server.xml.
<Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"
driverName="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://localhost/dbname?user=root&password=root"
userTable="users" userNameCol="email" userCredCol="password"
userRoleTable="user_roles" roleNameCol="role_name"/>
Additionally please note that I have included the required mysql jar file in tomcat's lib folder.
And here is my login form.
<form class="form" id="login_form" action="j_security_check" method="post">
<input class="element" id="element_1" style="WIDTH: 255px" maxlength="200" name="j_username"/>
<input class="element" id="element_2" style="WIDTH: 255px" type="password" maxlength="200" name="j_password"/>
</form>
Thanks guys for trying to help me here, I am really stuck on this!