what is best practice for user authentication ? realms or dummy

Hi Thank you for reading my post. I do not know what exactly a realm or jass do , i read it but i does not understand it yet. Here is my question : What is best practice for authenticating users? is it good to write a login page with a database and do all stuff myself ? eg comparing , adding the session attribute ... or it is better to use JAAS ? Realm (JDBCRealm) ... if i use JAAs or realms what pros and what conz in bring me ?