3

Having the ServletAPI plus the configurations you can make to jetty or any other web container

  1. Do we have a way to limit the request sizes ? (ie to close the connection if posting more that 50 MB)
  2. Can we in some way kill the dispatching of a request that is taking too long ?
  3. While dispatching a request in your own configured servlet, can we forward ( not redirect ) the request to the 'default' servlet. ? Will this allways work ?

    RequestDispatcher rd = getServletContext().getNamedDispatcher("default");
    HttpServletRequest wrapped = new HttpServletRequestWrapper(req) {
      public String getServletPath() { return ""; }
    }; 
    rd.forward(wrapped, resp);
    

Thanks in advance!

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
David Hofmann
  • 5,683
  • 12
  • 50
  • 78

1 Answers1

2

Spring has something to take care of this. If you're using Spring, you're in luck, or else you need to roll your own solution based on what Spring does. I can't speak for other frameworks, but I guess many other frameworks would have some support for this.

Take a look at org.springframework.web.multipart.commons.CommonsMultipartResolver and org.springframework.web.multipart.MaxUploadSizeExceededException

The CommonsMultipartResolver has a property maxUploadSize that lets you control the max size.

rahul
  • 1,281
  • 2
  • 12
  • 29
  • http://stackoverflow.com/questions/1414795/how-to-specify-http-request-timeout-parameter-on-java-servlet-container may have somthing of interest for you. However I'm not aware of anything in the servlet api that lets you cancel a request. – rahul Apr 02 '11 at 00:13