Simple java code for validating user in servlets