1 17 package servletunit.struts.tests; 18 19 import org.apache.struts.action.*; 20 21 import javax.servlet.ServletContext ; 22 import javax.servlet.http.HttpServletRequest ; 23 import javax.servlet.http.HttpServletResponse ; 24 25 public class InitParameterAction extends Action { 26 27 public ActionForward execute(ActionMapping mapping, 28 ActionForm form, 29 HttpServletRequest request, 30 HttpServletResponse response) { 31 32 ActionErrors errors = new ActionErrors(); 33 34 ServletContext context = getServlet().getServletContext(); 35 if (context != null) { 36 if (context.getInitParameter("username") == null) 37 errors.add("",new ActionMessage("error.init.param")); 38 } else 39 errors.add("",new ActionMessage("error.no.context")); 40 if (!errors.isEmpty()) 41 saveErrors(request,errors); 42 return mapping.findForward("login"); 43 } 44 45 } 46 | Popular Tags |