01: /**
02: * Copyright 2006 Webmedia Group Ltd.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: **/package org.araneaframework.example.common.framework.error;
16:
17: import java.io.Writer;
18: import org.apache.commons.lang.exception.ExceptionUtils;
19: import org.araneaframework.InputData;
20: import org.araneaframework.OutputData;
21: import org.araneaframework.Path;
22: import org.araneaframework.core.BaseService;
23: import org.araneaframework.http.HttpOutputData;
24:
25: public class TemplateCriticalErrorHandler extends BaseService {
26: protected Throwable exception;
27:
28: public TemplateCriticalErrorHandler(Throwable exception) {
29: this .exception = exception;
30: }
31:
32: protected void action(Path path, InputData input, OutputData output)
33: throws Exception {
34: Writer out = ((HttpOutputData) output).getWriter();
35:
36: ((HttpOutputData) output)
37: .setContentType("text/html; charset=UTF-8");
38: out
39: .write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"
40: + "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"
41: + "<head>\n"
42: + "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n"
43: + "<title>Critical Error!!!</title>\n"
44: + "\n"
45: + "<link rel=\"stylesheet\" type=\"text/css\" href=\"?loadCSSFile=styles/_styles_screen.css&importerType=cssFileImporter\" media=\"screen\"/>"
46: + "<link rel=\"stylesheet\" type=\"text/css\" href=\"?loadCSSFile=styles/_styles_global.css&importerType=cssFileImporter\" media=\"screen\"/>"
47: + "\n"
48: + "<!-- calendar -->\n"
49: + "<link href=\"calendar/calendar.css\" rel=\"stylesheet\" type=\"text/css\" media=\"screen, projection\" />\n"
50: + "<script type=\"text/javascript\" src=\"calendar/calendar.js\"></script>\n"
51: + "\n"
52: + "<script type=\"text/javascript\" src=\"calendar/calendar-ee.js\"></script>\n"
53: + "<script type=\"text/javascript\" src=\"calendar/calendar-setup.js\"></script>\n"
54: + "<!-- /calendar -->\n"
55: + "</head>\n"
56: + "\n"
57: + "<body id=\"error\">\n"
58: + "\n"
59: + "<div id=\"cont1\">\n"
60: + " <div id=\"header\">\n"
61: + " <div class=\"box1\">\n"
62: + " <a href=\"#\" id=\"logo\"><img src=\"gfx/logo_aranea_print.gif\" alt=\"\" /></a>\n"
63: + " </div>\n"
64: + "\n"
65: + " </div>\n"
66: + " <div class=\"stripe1\"> </div>\n"
67: + " <div id=\"wholder\">\n"
68: + " <div id=\"content\">\n"
69: + " <!-- start content -->\n"
70: + " <h1>Error</h1>\n"
71: + "<p><blockquote><a style='font-size: larger; text-decoration: underline' href='javascript:' onclick='javascript:window.location=window.location; return false'>Logout</a>"
72: + "<iframe width='0' height='0' src='?destroySession=true' style='display: none'></iframe></blockquote></p>"
73: + " <div class=\"msg-error\">\n"
74: + " <div style='overflow: auto;' id=\"crashinfo\">\n");
75: if (ExceptionUtils.getRootCause(exception) != null) {
76: out.write("<b>Root cause:</b><br/>");
77: out.write("<pre style=\'font-size: 10pt\'>"
78: + ExceptionUtils.getFullStackTrace(ExceptionUtils
79: .getRootCause(exception)) + "</pre>");
80: }
81: out.write("<b>Stack trace:</b><br/>");
82: out.write("<pre style=\'font-size: 10pt\'>"
83: + ExceptionUtils.getFullStackTrace(exception)
84: + "</pre>");
85: out.write("</body></html>");
86: out.write(" </div>\n" + " </div>\n"
87: + " <!-- end content -->\n" + " </div>\n" + "\n"
88: + " </div>\n" + " <div class=\"clear1\"> </div>\n"
89: + "</div>\n" + "\n" + "</body>\n" + "</html>\n" + "");
90: }
91: }
|