KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openlaszlo > servlets > responders > ResponderLOG


1 /******************************************************************************
2  * ResponderLOG.java
3  * ****************************************************************************/

4
5 /* J_LZ_COPYRIGHT_BEGIN *******************************************************
6 * Copyright 2001-2004 Laszlo Systems, Inc. All Rights Reserved. *
7 * Use is subject to license terms. *
8 * J_LZ_COPYRIGHT_END *********************************************************/

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