ctx.refresh();
UsersService usersService = ctx.getBean("usersService", UsersService.class);
PreferencesService preferenceService = ctx.getBean("preferencesService", PreferencesService.class);
BasicPasswordEncryptor passwordEncryptor = new BasicPasswordEncryptor();
String encryptedPassword = passwordEncryptor.encryptPassword(request.getParameter("pw"));
if(usersService.findById(request.getParameter("un")) != null) {
request.setAttribute("registrationMessage", "Username is already taken please regiser with another user name.");
String url = "/Register.jsp";
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(url);