3

For the testing purposes I need to make Tomcat to respond with late http responses. It is quite clear how to do it for the servlet responses. But it is not clear if I want Tomcat to answer, say with 10000 ms delay for each static file request. How it can be configured?

1

If I read this write - you want to introduce a 10000 ms delay for any incoming request where you are serving a static resource.

The easy way to do this is via a servlet filter mapped to the default servlet.

For brevity ...

doFilter(ServletRequest request, ServletResponse response, FilterChain chain)  {
    Thread.sleep(10000);
    chain.doFilter(request, response);
}

Then map the filter to the default servlet:

  <filter-mapping>
    <filter-name>delayFilter</filter-name>
    <servlet-name>default</servlet-name>
  </filter-mapping>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.