001: /*
002: * ErrorServlet.java
003: *
004: *
005: * Copyright (c) 2003 Rimfaxe ApS (www.rimfaxe.com).
006: * All rights reserved.
007: *
008: * This package is written by Lars Andersen <lars@rimfaxe.com>
009: * and licensed by Rimfaxe ApS.
010: *
011: * Redistribution and use in source and binary forms, with or without
012: * modification, are permitted provided that the following conditions
013: * are met:
014: *
015: * 1. Redistributions of source code must retain the above copyright
016: * notice, this list of conditions and the following disclaimer.
017: *
018: * 2. Redistributions in binary form must reproduce the above copyright
019: * notice, this list of conditions and the following disclaimer in
020: * the documentation and/or other materials provided with the
021: * distribution.
022: *
023: * 3. The end-user documentation included with the redistribution, if
024: * any, must include the following acknowlegement:
025: * "This product includes software developed by Rimfaxe ApS
026: (www.rimfaxe.com)"
027: * Alternately, this acknowlegement may appear in the software itself,
028: * if and wherever such third-party acknowlegements normally appear.
029: *
030: * 4. The names "Rimfaxe", "Rimfaxe Software", "Lars Andersen" and
031: * "Rimfaxe WebServer" must not be used to endorse or promote products
032: * derived from this software without prior written permission. For written
033: * permission, please contact info@rimfaxe.com
034: *
035: * 5. Products derived from this software may not be called "Rimfaxe"
036: * nor may "Rimfaxe" appear in their names without prior written
037: * permission of the Rimfaxe ApS.
038: *
039: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
040: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
041: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
042: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
043: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
044: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
045: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
046: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
047: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
048: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
049: * SUCH DAMAGE.
050: *
051: */
052:
053: package com.rimfaxe.webserver.servletapi.standard;
054:
055: import javax.servlet.*;
056: import javax.servlet.http.*;
057:
058: /**
059: *
060: * @author Lars Andersen
061: */
062: public class ErrorServlet extends HttpServlet {
063:
064: /** Initializes the servlet.
065: */
066: public void init(ServletConfig config) throws ServletException {
067: super .init(config);
068: }
069:
070: /** Destroys the servlet.
071: */
072: public void destroy() {
073: }
074:
075: /** Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
076: * @param request servlet request
077: * @param response servlet response
078: */
079: protected void processRequest(HttpServletRequest request,
080: HttpServletResponse response) throws ServletException,
081: java.io.IOException {
082: response.setContentType("text/html");
083: java.io.PrintWriter out = response.getWriter();
084:
085: out.println("<html>");
086: out.println("<head>");
087: out.println("<title>Rimfaxe Web Server - Error report</title>");
088: out.println("</head>");
089: out.println("<body>");
090: out
091: .println("<table border=\"1\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">");
092: out.println("<tr>");
093: out.println("<td height=\"50\" bgcolor=\"orange\">");
094: out
095: .println("<p style=\"margin-left: 10px; font-weight: bold; font-size: 16pt\">");
096: out.println("Rimfaxe Web Server - Error report");
097: out.println("</p>");
098: out.println("</td>");
099: out.println("</tr>");
100: out.println("<tr>");
101: out.println("<td>");
102: out
103: .println("<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">");
104: out.println("<tr>");
105: out.println("<td>");
106:
107: out
108: .println("<br><p style=\"margin-left: 10px; font-size: 12pt; font-weight: bold\">");
109: out.println(""
110: + this .getServletConfig().getInitParameter(
111: "com.rimfaxe.error_found"));
112: out.println("</p>");
113:
114: out.println("<p style=\"margin-left: 10px; font-size: 10pt\">");
115: out.println(""
116: + this .getServletConfig().getInitParameter(
117: "com.rimfaxe.error_msg"));
118: out.println("</p><br> <br>");
119: out.println("</td>");
120: out.println("</tr>");
121: out.println("</table>");
122: out.println("</td>");
123: out.println("</tr>");
124: out.println("<tr>");
125: out.println("<td height=\"15\" bgcolor=\"orange\">");
126: out
127: .println("<p style=\"margin-left: 10px; font-color: white; font-size: 10pt\">");
128: out
129: .println("<b>"
130: + com.rimfaxe.webserver.ObjectStore
131: .getConfiguration().getBanner()
132: + "</b> - <a href=\"http://www.rimfaxe.com\">Rimfaxe Software</a>");
133: out.println("</p>");
134: out.println("</td>");
135: out.println("</tr>");
136: out.println("</table>");
137: out.println("</body>");
138: out.println("</html>");
139: out.close();
140: }
141:
142: /** Handles the HTTP <code>GET</code> method.
143: * @param request servlet request
144: * @param response servlet response
145: */
146: protected void doGet(HttpServletRequest request,
147: HttpServletResponse response) throws ServletException,
148: java.io.IOException {
149: processRequest(request, response);
150: }
151:
152: /** Handles the HTTP <code>POST</code> method.
153: * @param request servlet request
154: * @param response servlet response
155: */
156: protected void doPost(HttpServletRequest request,
157: HttpServletResponse response) throws ServletException,
158: java.io.IOException {
159: processRequest(request, response);
160: }
161:
162: /** Returns a short description of the servlet.
163: */
164: public String getServletInfo() {
165: return "Short description";
166: }
167:
168: }
|