public static void sendError(HttpServletRequest request,HttpServletResponse response,int httpStatusCode,String errorCode,String errorMsg){
  if ((errorUrl == null) || (errorUrl.length() == 0)) {
    try {
      response.sendError(httpStatusCode,errorMsg);
      return;
    }
 catch (    IOException ioe) {
      debug.error("CookieUtils.sendError",ioe);
    }
  }
 else {
    String jointString="?";
    if (errorUrl.indexOf("?") != -1) {
      jointString="&";
    }
    String newUrl=errorUrl.trim() + jointString + "errorcode="+ errorCode+ "&"+ "httpstatuscode="+ httpStatusCode+ "&"+ "errormessage="+ URLEncDec.encode(errorMsg);
    if (debug.messageEnabled()) {
      debug.message("CookieUtils.sendError: final redirectionURL=" + newUrl);
    }
    String tmp=errorUrl.toLowerCase();
    if (tmp.startsWith("http://") || tmp.startsWith("https://")) {
      try {
        response.sendRedirect(newUrl);
      }
 catch (      IOException e) {
        debug.error("CookieUtils.sendError: Exception " + "occured while trying to redirect to resource:" + newUrl,e);
      }
    }
 else {
      try {
        RequestDispatcher dispatcher=request.getRequestDispatcher(newUrl);
        dispatcher.forward(request,response);
      }
 catch (      ServletException e) {
        debug.error("CookieUtils.sendError: Exception " + "occured while trying to forward to resource:" + newUrl,e);
      }
catch (      IOException e) {
        debug.error("CookieUtils.sendError: Exception " + "occured while trying to forward to resource:" + newUrl,e);
      }
    }
  }
}

public static void sendError ( HttpServletRequest request , HttpServletResponse response , int httpStatusCode , String errorCode , String errorMsg ) { if ( ( errorUrl == null ) || ( errorUrl . length ( ) == 0 ) ) { try { response . sendError ( httpStatusCode , errorMsg ) ; return ; } catch ( IOException ioe ) { debug . error ( "CookieUtils.sendError" , ioe ) ; } } else { String jointString = "?" ; if ( errorUrl . indexOf ( "?" ) != - 1 ) { jointString = "&" ; } String newUrl = errorUrl . trim ( ) + jointString + "errorcode=" + errorCode + "&" + "httpstatuscode=" + httpStatusCode + "&" + "errormessage=" + URLEncDec . encode ( errorMsg ) ; if ( debug . messageEnabled ( ) ) { debug . message ( "CookieUtils.sendError: final redirectionURL=" + newUrl ) ; } String tmp = errorUrl . toLowerCase ( ) ; if ( tmp . startsWith ( "http://" ) || tmp . startsWith ( "https://" ) ) { try { response . sendRedirect ( newUrl ) ; } catch ( IOException e ) { debug . error ( "CookieUtils.sendError: Exception " + "occured while trying to redirect to resource:" + newUrl , e ) ; } } else { try { RequestDispatcher dispatcher = request . getRequestDispatcher ( newUrl ) ; dispatcher . forward ( request , response ) ; } catch ( ServletException e ) { debug . error ( "CookieUtils.sendError: Exception " + "occured while trying to forward to resource:" + newUrl , e ) ; } catch ( IOException e ) { debug . error ( "CookieUtils.sendError: Exception " + "occured while trying to forward to resource:" + newUrl , e ) ; } } } }
sends to error page url for processing . if the error page is hosted in the same web application , forward is used with parameters . otherwise , redirection is used with parameters . three parameters are passed to the error url : - - errorcode : error key , this is the i18n key of the error message . - - httpstatuscode : http status code for the error - - message : detailed i18n ' d error message
