com.addc.server.commons.struts12.actions.ErrorAction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of addc-svr-struts12 Show documentation
Show all versions of addc-svr-struts12 Show documentation
Classes to support web apps written for struts 1.2.
package com.addc.server.commons.struts12.actions;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.Globals;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The ErrorAction supplies a struts action for error pages
*/
@SuppressWarnings("PMD")
public class ErrorAction extends DispatchAction {
private static final Logger LOGGER= LoggerFactory.getLogger(ErrorAction.class);
@SuppressWarnings("unused")
public ActionForward preparePage(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
ActionForward forward= mapping.findForward(ActionConstants.SUCCESS_FORWARD);
ErrorActionForm actionForm= (ErrorActionForm) form;
try {
actionForm.setErrorCode((String) request.getAttribute(Globals.ERROR_KEY));
Exception exception= (Exception) request.getAttribute(Globals.EXCEPTION_KEY);
actionForm.setException(exception.getMessage());
LOGGER.info("{}", actionForm);
} catch (Exception e) {
actionForm.setErrorCode("Internal Error: " + e.getMessage());
}
return forward;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy