public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
// Extract attributes we will need
HttpSession session = request.getSession();
// Get locale from request, if any
Locale locale = request.getLocale();
// If supplied, set Locale based on request parameters;
// country and language
String language = request.getParameter("language");
String country = request.getParameter("country");
if ((language != null && language.length() > 0)
&& (country != null && country.length() > 0)) {
locale = new java.util.Locale(language, country);
} elseif (language != null && language.length() > 0) {
locale = new java.util.Locale(language, "");
}
//Save locale
session.setAttribute(Globals.LOCALE_KEY, locale);
// Forward to result page
return mapping.findForward("success");
}
|