1 18 package org.apache.struts.webapp.example; 19 20 import java.util.ArrayList ; 21 import javax.servlet.http.HttpServletRequest ; 22 import javax.servlet.http.HttpServletResponse ; 23 import org.apache.struts.webapp.example.UserDatabase; 24 import org.apache.struts.util.MessageResources; 25 import org.apache.struts.action.ActionForm; 26 import org.apache.struts.action.ActionMapping; 27 import org.apache.struts.action.ActionForward; 28 29 30 45 public final class WelcomeAction extends BaseAction { 46 47 49 public ActionForward execute( 51 ActionMapping mapping, 52 ActionForm form, 53 HttpServletRequest request, 54 HttpServletResponse response) 55 throws Exception { 56 57 ArrayList messages = new ArrayList (); 59 60 MessageResources resources = getResources(request); 62 if (resources==null) { 63 messages.add(Constants.ERROR_MESSAGES_NOT_LOADED); 64 } 65 66 UserDatabase userDatabase = getUserDatabase(request); 68 if (userDatabase==null) { 69 messages.add(Constants.ERROR_DATABASE_NOT_LOADED); 70 } 71 72 if (messages.size()>0) { 74 request.setAttribute(Constants.ERROR_KEY,messages); 75 return findFailure(mapping); 76 } 77 78 return findSuccess(mapping); 80 81 } 82 83 } 84 | Popular Tags |