23-Spring MVC - Project Work | Login Task List & Business Method (Contact App) - By eZeon

Опубликовано: 14 Март 2026
на канале: Vikram Thakur
5,094
43

This Project Work(Contact App) video is based on LOGIN TASKS AND AUTHENTICATION LOGIC.

TASK LIST FOR LOGIN OPERATION:
1. UserService - check business logic implementation code for user authentication
2. Prepare Dashboard Pages for - Admin and User Roles (link to UserController)
3. Login Form + LoginCommand + Spring MVC Form Taglib
4. Show error messages correctly + JSTL Core Tablib
5. Bind Logged in user with HttpSession scope for further use
6. Role wise menu display

AUTHENTICATION LOGIC:
//UserService.java
public interface UserService {
/**
The method handles login operation(authentication) using given credentials,
it returns User object when success and null when failed.
When user account is blocked an exception will be thrown by this method.
@param loginName
@param password
@return
@throws in.ezeon.capp.exception.UserBlockedException When user account is blocked.
*/
public User login(String loginName, String password) throws UserBlockedException;

//other method goes here...
}

//UserServiceImpl.java
/**
*
@author Vikram
*/
@Service
public class UserServiceImpl extends BaseDAO implements UserService {
@Autowired
private UserDAO userDAO;

@Override
public void register(User u) {
userDAO.save(u);
}
@Override
public User login(String loginName, String password) throws UserBlockedException {
String sql = "SELECT userId, name, phone, email, address, role, loginStatus, loginName"
" FROM user WHERE loginName=:ln AND password=:pw";
Map m = new HashMap();
m.put("ln", loginName);
m.put("pw", password);
try {
User u = getNamedParameterJdbcTemplate().queryForObject(sql, m, new UserRowMapper());
if(u.getLoginStatus().equals(UserService.LOGIN_STATUS_BLOCKED)){
throw new UserBlockedException("Your accout has been blocked. Contact to admin.");
}else{
return u;
}
} catch (EmptyResultDataAccessException ex) {
return null;
}
}
//impl of other method goes here
}

Don't skip or miss any video, just follow step by step video series.
Also check the source code listing in our
blog http://ezeon.in/blog

SUBSCRUBE my channel for more videos on Java Technologies and Software Development including all advanced development frameworks and technologies.