1 2 package org.nemesis.forum.webapp.admin.action; 3 4 import java.util.Locale ; 5 6 import javax.servlet.http.HttpServletRequest ; 7 import javax.servlet.http.HttpServletResponse ; 8 9 import org.apache.commons.beanutils.PropertyUtils; 10 import org.apache.struts.Globals; 11 import org.apache.struts.action.ActionError; 12 import org.apache.struts.action.ActionErrors; 13 import org.apache.struts.action.ActionForm; 14 import org.apache.struts.action.ActionForward; 15 import org.apache.struts.action.ActionMapping; 16 import org.nemesis.forum.util.CookieManager; 17 18 19 20 21 22 31 public class LogonAction extends BaseAction { 32 33 public ActionForward execute(ActionMapping mapping, 34 ActionForm form, 35 HttpServletRequest request, 36 HttpServletResponse response) 37 throws Exception { 38 39 40 ActionErrors errors = new ActionErrors(); 41 String username = (String )PropertyUtils.getSimpleProperty(form, "username"); 42 String password = (String )PropertyUtils.getSimpleProperty(form, "password"); 43 String language = (String )PropertyUtils.getSimpleProperty(form, "language"); 44 45 Locale l=new Locale (language); setLocale(request,l); 47 request.getSession().setAttribute(Globals.LOCALE_KEY, l); 48 CookieManager.setCookie(response,"language",language,CookieManager.MAX_COOKIE_AGE); 49 50 51 try { 53 54 super.authenticate(request,username,password); 55 56 } catch (Exception e) { 57 58 errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("logon.error.badLogin")); 59 saveErrors(request, errors); 60 return (mapping.getInputForward()); 61 62 } 63 64 65 66 73 74 return (mapping.findForward("success")); 76 77 78 } 79 80 } 81 | Popular Tags |