<%@ taglib uri="struts-bean"  prefix="bean"  %>
<%@ taglib uri="struts-html"  prefix="html"  %>
<%@ taglib uri="struts-logic" prefix="logic" %>
<%@ taglib uri="vkc-taglib"   prefix="vkc"   %>

<%@ page import="org.apache.struts.Globals" %>
<%@ page import="vkc.view.WebShare"         %>

<%
    Throwable ex = (Exception)pageContext.findAttribute( "exception" );
	if ( ex==null ) {
		ex = (Exception)request.getAttribute( "javax.servlet.jsp.jspException" );
	}

    if ( ex==null ) {
        ex = (Exception)request.getAttribute( Globals.EXCEPTION_KEY );
    }

	if ( ex==null ) {
		return;
	}

    if ( ex instanceof ServletException ) {
        ServletException e = (ServletException)ex;
        Throwable rootCause = e.getRootCause();
        if ( rootCause!=null ) {
            ex = rootCause;
        }
    }

    String errorId = "errorId." + System.currentTimeMillis();
    WebShare.getTraceLogger().logStackTrace( ex, errorId );
    String adminEmail = WebShare.getSysParameterValue("MAIL", "AdminEmail", "admin@company.com");
%>

<html>
<head>

  <META HTTP-EQUIV="Content-Type"        CONTENT="text/html; charset=iso-8859-1">
  <META HTTP-EQUIV="Content-Script-Type" CONTENT="text/javascript">
  <META HTTP-EQUIV="Content-Style-Type"  CONTENT="text/css">
  <META HTTP-EQUIV="cache"               CONTENT="no-cache">
  <META HTTP-EQUIV="cache-control"       CONTENT="no-cache">
  <META HTTP-EQUIV="pragma"              CONTENT="no-cache">
  <META HTTP-EQUIV="expires"             CONTENT="0">

  <vkc:cssinclude />

  <style type="text/css">
	body {
	    font-family: sans-serif;
	    font-size:13px;
	    background-color:#f2f2f2;
	}
	
	td, table {
	    font-family: sans-serif;
	    font-size:13px;
	}
  </style>  	

</head>

<body marginwidth="0" marginheight="0">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td align="center" width="100%">

      <table width="100%" border="0" cellspacing="1" cellpadding="3">

        <tr><td align="center">&nbsp;</td></tr>

        <tr>
          <td align="center">
            <b><vkc:img page="/common/images/error.gif" border="0" alt=""/>
            	&nbsp;<vkc:message key="vkc.error.exceptionOccured"/>
            </b>
          </td>
        </tr>

        <tr><td align="center">&nbsp;</td></tr>

        <tr>
          <td align="center">
          	<vkc:message key="vkc.error.pleaseContact"/>
            <a href="mailto:<%=adminEmail%>?subject=VKC: <vkc:message key='vkc.error.systemFailure'/> <%=errorId%>" title="<vkc:message key='vkc.error.mailToAdmin'/>"><b><vkc:message key="vkc.error.appropriateAdmin"/></b></a>
	        <vkc:message key="vkc.error.ifTheFailureStillOccurs"/>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>

<%  String trace = vkc.util.VKCUtils.getStackTrace( ex ); %>
<%  trace =  vkc.util.StringUtils.replaceChar( trace, '\n', "<br>"); %>
  <table width="100%" border="0" cellspacing="1" cellpadding="3">

    <vkc:hline topSpace="30" bottomSpace="10" lineHeight="1" lineClass="hline" colspan="3"/>

    <tr>
      <td align="center">&nbsp;</td>
      <td width="100%" align="left" valign="top">Stacktrace:&nbsp;<br><%=trace%></td>
      <td align="center">&nbsp;</td>
    </tr>

  </table>
</body>
</html>
