01: package com.jat.admin;
02:
03: import java.io.IOException;
04: import javax.servlet.ServletConfig;
05: import javax.servlet.ServletException;
06: import javax.servlet.http.HttpServlet;
07: import javax.servlet.http.HttpServletRequest;
08: import javax.servlet.http.HttpServletResponse;
09:
10: import com.jat.core.log.LogManager;
11:
12: /**
13: * <p>Title: JAT</p>
14: * <p>Description: </p>
15: * <p>Copyright: Copyright (c) 2004 -2005 Stefano Fratini (stefano.fratini@gmail.com)</p>
16: * <p>Distributed under the terms of the GNU Lesser General Public License, v2.1 or later</p>
17: * @author stf
18: * @version 1.0
19: */
20:
21: public class LogManagerServlet extends HttpServlet {
22:
23: public void doPost(HttpServletRequest request,
24: HttpServletResponse response) throws ServletException,
25: IOException {
26: checkParams(request);
27: forward(request, response);
28: }
29:
30: public void doGet(HttpServletRequest request,
31: HttpServletResponse response) throws ServletException,
32: IOException {
33: forward(request, response);
34: }
35:
36: public void checkParams(HttpServletRequest request) {
37: String update = request.getParameter("Update");
38: if (update != null && update.equals("Update")) {
39: /*
40: String error = request.getParameter("error");
41: boolean active = (error!= null && error.equals("error"));
42: LogManager.getError().setActive(active);
43: */
44:
45: String log = request.getParameter("log");
46: boolean active = (log != null && log.equals("log"));
47: LogManager.getLog().setActive(active);
48:
49: String debug = request.getParameter("debug");
50: active = (debug != null && debug.equals("debug"));
51: LogManager.getDebug().setActive(active);
52:
53: String time = request.getParameter("time");
54: active = (time != null && time.equals("time"));
55: LogManager.getTime().setActive(active);
56: }
57: }
58:
59: public void forward(HttpServletRequest req, HttpServletResponse resp)
60: throws ServletException, IOException {
61: String root = "";
62: try {
63: root = com.jat.core.config.Config.getCurrent().getValue(
64: "admin", "root");
65: } catch (Exception ex) {
66: throw new ServletException(ex);
67: }
68: this .getServletContext().getRequestDispatcher(
69: root + "log/LogManager.jsp").forward(req, resp);
70: }
71:
72: public void init(ServletConfig config) throws ServletException {
73: super.init(config);
74: }
75:
76: }
|