<%@ page import="org.springframework.security.ui.rememberme.TokenBasedRememberMeServices" %>
<%@ page import="javax.servlet.http.Cookie" %>
<%@ page import="java.io.PrintWriter" %>
<%@ page import="java.util.Date" %>
<%@ page language="java" isErrorPage="true" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="/struts-tags" prefix="s" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
    <title><fmt:message key="title.500"/></title>
    <link rel="stylesheet" type="text/css" media="all"
          href="<c:url value='/styles/${appConfig["csstheme"]}/theme.css'/>"/>
    <style type="text/css">
        div.Metadata { background: white; display: block; width: 80%; }
        div.Metadata dl dt { width: 20%; clear: right; }
        div.Metadata dl dd { width: 80%; }
    </style>
</head>

<body id="error">
 <div class="fullContent">
 	<div class="TabPanel Pane" id="404">
            <h2><fmt:message key="title.500"/></h2>
            <p><fmt:message key="text.500"/></p>
            <% if (exception != null) { %>

            <% PrintWriter writer = new java.io.PrintWriter(out);
               boolean end = false;
                String exceptionString = "";
                Throwable cause = exception;
                // Find root cause
                while(!end){
                    exceptionString += cause.toString();
                    exceptionString += " at " + cause.getStackTrace()[0].toString() + "<br/>";
                    if(cause.getCause() != null){
                        cause = cause.getCause();
                    } else {
                        end = true;
                    }
                }

            %>
            <div class="Metadata">
            <dl>
                <dt>Host:</dt>
                    <dd> <% writer.write(request.getServerName() + ":" + request.getServerPort()); %></dd>
                <dt>Error:</dt><dd><% writer.write(exception.getClass().getName().toString()); %></dd>
                <dt>Error Detail:</dt><dd><% writer.write(exceptionString); %></dd>
                <dt>Java:</dt>
                    <dd>
                        <% writer.write(System.getProperty("java.vendor")); %>
                        <% writer.write(System.getProperty("java.version")); %>
                        <% writer.write(System.getProperty("java.home")); %>
                    </dd>
                <dt>Machine:</dt>
                    <dd>
                        <% writer.write(System.getProperty("os.name")); %>
                        <% writer.write(System.getProperty("os.arch")); %>
                        <% writer.write(System.getProperty("os.version")); %>
                    </dd>
                <dt>Browser:</dt>
                    <dd> <% writer.write(request.getHeader("User-Agent")); %></dd>
                <dt>fixx version:</dt>
                    <dd><fmt:message key="webapp.version"/></dd>
                <dt>Time:</dt>
                    <dd><% writer.write(new Date().toString()); %></dd>
            </dl>

            <% } else if (request.getAttribute("javax.servlet.error.exception") != null) { %>
                    <% ((Exception) request.getAttribute("javax.servlet.error.exception"))
                            .printStackTrace(new java.io.PrintWriter(out)); %>
            <% } %>
            </div>
            <div class="hide">
                 <% ((Exception) request.getAttribute("javax.servlet.error.exception"))
                            .printStackTrace(new java.io.PrintWriter(out)); %>
            </div>
        </div>
    </div>
</div>
</body>
</html>
