<%@ page session="false" isErrorPage="true" contentType="text/html" import="
	org.opencms.jsp.util.*,org.opencms.file.*,org.opencms.main.*,org.opencms.frontend.templatetwo.*
"%><%

// initialize instance of status bean
CmsJspStatusBean cms = new CmsJspStatusBean(pageContext, request, response, exception);

// get the template to use
String template = null;
String path = cms.getRequestResourceName();
do {
	try {
		path = CmsResource.getParentFolder(path);
		if (path == null) {
			break;
		}
		template = cms.getCmsObject().readPropertyObject(cms.getSiteRoot() + path, "template", true).getValue();
	} catch (CmsException ex) {
		out.println(ex.getMessage());
	}
} while (template == null);

if (template != null && template.equals(CmsTemplateLayout.VFS_PATH_TEMPLATE)) {
	cms.setTemplateUri(path);
} else {
	template = cms.property("template", "search", "/system/handler/template/handlertemplate");
}

// include the template head part
cms.includeTemplatePart(template, "head");

%>
<%= cms.getPageContent("head") %>

<!-- Status error messages start -->
<h4><%= cms.key("error_message_servererror") %></h4>
<h3><%= cms.keyStatus("error_message") %></h3>

<p><%= cms.keyStatus("error_description") %></p>

<% if (cms.showException() && cms.getErrorMessage() != null) {
	// print the error message for developers, if available
	out.print("<p><b>" + cms.getErrorMessage() + "</b></p>");
}

if (cms.showException() && cms.getException() != null) { 
	// print the exception for developers, if available
%>
<p><b><%= cms.getException() %></b></p>
<p><pre>
<% cms.getException().printStackTrace(new java.io.PrintWriter(out)); %>
</pre></p>
<% } %>
<!-- Status error messages end -->

<%= cms.getPageContent("foot") %>
<%

// include the template foot part
cms.includeTemplatePart(template, "foot");

// set the original error status code for the returned page
Integer status = cms.getStatusCode();
if (status != null) {
	cms.setStatus(status.intValue());
}
%>