SHARE
TWEET

Untitled

a guest Jun 15th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <Valve className="org.apache.catalina.connector.MyValve"
  2.     classField="value">
  3.      
  4. <dependency>
  5.             <groupId>org.apache.tomcat</groupId>
  6.             <artifactId>tomcat-catalina</artifactId>
  7.             <version>7.0.85</version>
  8.             <scope>provided</scope>
  9. </dependency>
  10.      
  11. import java.io.IOException;
  12. import java.util.Enumeration;
  13. import java.util.logging.Level;
  14. import java.util.logging.Logger;
  15.  
  16. import org.apache.catalina.connector.Request;
  17. import org.apache.catalina.connector.Response;
  18. import org.apache.catalina.valves.ValveBase;
  19.  
  20. import javax.servlet.ServletException;
  21. import javax.servlet.http.HttpServletRequest;
  22.  
  23. /**
  24.  * @author Keet Sugathadasa
  25.  */
  26. public class TomcatValve extends ValveBase {
  27.     private static final Logger logger = Logger.getLogger(TomcatValve.class.getName());
  28.  
  29.     public void invoke(Request request, Response response) throws IOException, ServletException {
  30.         HttpServletRequest httpServletRequest = request.getRequest();
  31.  
  32.         Enumeration<String> headerNames = httpServletRequest.getHeaderNames();
  33.  
  34.         logger.info("Receiving request");
  35.  
  36.         while (headerNames.hasMoreElements()) {
  37.             String header = headerNames.nextElement();
  38.             logger.log(Level.INFO, "Header --> {0} Value --> {1}", new Object[]{header, httpServletRequest.getHeader(header)});
  39.         }
  40.  
  41.         getNext().invoke(request, response);
  42.     }
  43. }
  44.      
  45. <Valve className="com.keetmalin.tomcat.TomcatValve"/>
  46.      
  47. ./catalina.sh run
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top