1   /**
2    * Logback: the reliable, generic, fast and flexible logging framework.
3    * Copyright (C) 1999-2015, QOS.ch. All rights reserved.
4    *
5    * This program and the accompanying materials are dual-licensed under
6    * either the terms of the Eclipse Public License v1.0 as published by
7    * the Eclipse Foundation
8    *
9    *   or (per the licensee's choosing)
10   *
11   * under the terms of the GNU Lesser General Public License version 2.1
12   * as published by the Free Software Foundation.
13   */
14  package ch.qos.logback.access.common;
15  
16  import jakarta.servlet.ServletContext;
17  import jakarta.servlet.http.HttpServletRequest;
18  import jakarta.servlet.http.HttpServletResponse;
19  
20  import ch.qos.logback.core.status.StatusManager;
21  import ch.qos.logback.core.status.ViewStatusMessagesServletBase;
22  
23  public class ViewStatusMessagesServlet extends ViewStatusMessagesServletBase {
24  
25      private static final long serialVersionUID = 443878494348593337L;
26  
27      @Override
28      protected StatusManager getStatusManager(HttpServletRequest req, HttpServletResponse resp) {
29  
30          ServletContext sc = getServletContext();
31          return (StatusManager) sc.getAttribute(AccessConstants.LOGBACK_STATUS_MANAGER_KEY);
32  
33          // if (result != null) {
34          // System.out.println("from ServletContext");
35          // return result;
36          // } else {
37          // HttpSession httpSession = req.getSession(true);
38          //
39          // System.out.println("from httpSession");
40          // return (StatusManager) httpSession
41          // .getAttribute(AccessConstants.LOGBACK_STATUS_MANAGER_KEY);
42          // }
43      }
44  
45      @Override
46      protected String getPageTitle(HttpServletRequest req, HttpServletResponse resp) {
47          return "<h2>Status messages for logback-access</h2>\r\n";
48      }
49  }