01: /******************************************************************************
02: * ResponderLOG.java
03: * ****************************************************************************/package org.openlaszlo.servlets.responders;
04:
05: import java.io.*;
06: import java.util.Properties;
07: import javax.servlet.ServletConfig;
08: import javax.servlet.ServletException;
09: import javax.servlet.ServletOutputStream;
10: import javax.servlet.http.HttpServletRequest;
11: import javax.servlet.http.HttpServletResponse;
12: import org.openlaszlo.utils.FileUtils;
13: import org.openlaszlo.server.LPS;
14: import org.apache.log4j.Logger;
15:
16: public final class ResponderLOG extends ResponderAdmin {
17: private static Logger mLogger = Logger
18: .getLogger(ResponderLOG.class);
19:
20: protected void respondAdmin(HttpServletRequest req,
21: HttpServletResponse res) throws IOException {
22: ServletOutputStream out = res.getOutputStream();
23: FileInputStream in = null;
24: try {
25: res.setContentType("text/html");
26: out.println("<html><head><title>LPS Log</title></head>");
27: out.println("<body><pre>");
28: File logFile = ResponderLOGCONFIG.getLogFile();
29: if (logFile != null) {
30: in = new FileInputStream(logFile);
31: FileUtils.escapeHTMLAndSend(in, out);
32: } else {
33: out.println("No log file.");
34: }
35: out.println("</pre></body></html>");
36: mLogger.info(
37: /* (non-Javadoc)
38: * @i18n.test
39: * @org-mes="Sent log"
40: */
41: org.openlaszlo.i18n.LaszloMessages.getMessage(
42: ResponderLOG.class.getName(), "051018-49"));
43: } finally {
44: FileUtils.close(in);
45: FileUtils.close(out);
46: }
47: }
48:
49: public int getMimeType() {
50: return MIME_TYPE_HTML;
51: }
52: }
|