1 23 24 25 package org.infoglue.deliver.applications.actions; 26 27 import javax.servlet.RequestDispatcher ; 28 import javax.servlet.http.HttpServletResponse ; 29 30 import org.infoglue.cms.applications.common.actions.InfoGlueAbstractAction; 31 import org.infoglue.cms.util.CmsPropertyHandler; 32 33 34 39 40 public class ErrorPageAction extends InfoGlueAbstractAction 41 { 42 private int responseCode = HttpServletResponse.SC_INTERNAL_SERVER_ERROR; 43 44 47 48 public String doExecute() throws Exception 49 { 50 String responseCodeAttribute = (String )this.getRequest().getAttribute("responseCode"); 51 if(responseCodeAttribute != null) 52 responseCode = Integer.parseInt(responseCodeAttribute); 53 54 String responseCodeParameter = (String )this.getRequest().getParameter("responseCode"); 55 if(responseCodeParameter != null) 56 responseCode = Integer.parseInt(responseCodeParameter); 57 58 Exception e = (Exception )this.getRequest().getAttribute("error"); 59 if(e != null) 60 { 61 setError(e, e.getCause()); 62 } 63 64 this.getResponse().setContentType("text/html; charset=UTF-8"); 65 this.getResponse().setStatus(responseCode); 66 67 String errorUrl = CmsPropertyHandler.getErrorUrl(); 68 if(errorUrl != null && errorUrl.indexOf("@errorUrl@") == -1) 69 { 70 if(errorUrl.indexOf("http") > -1) 71 this.getResponse().sendRedirect(errorUrl); 72 else 73 { 74 RequestDispatcher dispatch = this.getRequest().getRequestDispatcher(errorUrl); 75 this.getRequest().setAttribute("error", e); 76 dispatch.include(this.getRequest(), this.getResponse()); 78 } 79 80 return NONE; 81 } 82 else 83 return SUCCESS; 84 } 85 86 89 90 public String doBusy() throws Exception 91 { 92 String responseCodeAttribute = (String )this.getRequest().getAttribute("responseCode"); 93 if(responseCodeAttribute != null) 94 responseCode = Integer.parseInt(responseCodeAttribute); 95 96 String responseCodeParameter = (String )this.getRequest().getParameter("responseCode"); 97 if(responseCodeParameter != null) 98 responseCode = Integer.parseInt(responseCodeParameter); 99 100 Exception e = (Exception )this.getRequest().getAttribute("error"); 101 if(e != null) 102 { 103 setError(e, e.getCause()); 104 } 105 106 this.getResponse().setContentType("text/html; charset=UTF-8"); 107 this.getResponse().setStatus(responseCode); 108 109 String errorUrl = CmsPropertyHandler.getErrorBusyUrl(); 110 if(errorUrl != null && errorUrl.indexOf("@errorBusyUrl@") == -1) 111 { 112 if(errorUrl.indexOf("http") > -1) 113 this.getResponse().sendRedirect(errorUrl); 114 else 115 { 116 RequestDispatcher dispatch = this.getRequest().getRequestDispatcher(errorUrl); 117 this.getRequest().setAttribute("error", e); 118 dispatch.include(this.getRequest(), this.getResponse()); 120 } 121 122 return NONE; 123 } 124 else 125 return SUCCESS; 126 } 127 128 public int getResponseCode() 129 { 130 return responseCode; 131 } 132 } 133 | Popular Tags |