Class HttpEchoServlet

  • All Implemented Interfaces:
    Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

    public class HttpEchoServlet
    extends javax.servlet.http.HttpServlet
    An HttpServlet to echo the HttpServletRequest with headers and payload as HTML output in the HttpServletResponse. This is very helpful especially if your application is behind a complex infrastructure with reverse-proxies, etc.
    In order to use this servlet simply add the following to your spring configuration (and adjust "/debug/echo/*" to your needs):
     @Bean
     public ServletRegistrationBean echoServletRegistration() {
    
       HttpEchoServlet echoServlet = new HttpEchoServlet();
       ServletRegistrationBean registration = new ServletRegistrationBean(echoServlet);
       registration.addUrlMappings("/debug/echo/*");
       return registration;
     }
     
    See Also:
    Serialized Form
    • Constructor Detail

      • HttpEchoServlet

        public HttpEchoServlet()
        Der Konstruktor.
    • Method Detail

      • service

        protected void service​(javax.servlet.http.HttpServletRequest request,
                               javax.servlet.http.HttpServletResponse response)
                        throws javax.servlet.ServletException,
                               IOException
        Overrides:
        service in class javax.servlet.http.HttpServlet
        Throws:
        javax.servlet.ServletException
        IOException
      • printHeaders

        private void printHeaders​(javax.servlet.http.HttpServletRequest request,
                                  PrintWriter out)
      • getSecuredValue

        private String getSecuredValue​(String originalHeaderName,
                                       String value)