HttpSession userSession = request.getSession();
Locale userLocale = null;
if (userSession.isNew()) {
String language = request.getParameter("language");
language = nullToEmpty(language);
String country = request.getParameter("country");
country = nullToEmpty(country);
String variant = request.getParameter("variant");
variant = nullToEmpty(variant);
userLocale = new Locale(language, country, variant);
userSession.setAttribute("userLocale", userLocale);
} else {
userLocale = (Locale)userSession.getAttribute("userLocale");
}