Maximum size of XML file as response in Servlet

Discussions

General J2EE: Maximum size of XML file as response in Servlet

  1. Hi all

    What is the maximum size(in MB) of an XML file written to output in a servelt as response?
    Also can we set a limitation on the file size before output as response??

    Thankx
    Chandra
  2. In theory, there is no limit. In practice, the limit depends on your hardware, speed of your network connection, amount of memory your JVM has available and many other factors.

    I would not recommend XML files larger than 1 MB; XML does not work very well for large data-sets. If you need to send out more data than that, either (a) send it another way (b) find a way to break the XML up into smaller chunks or (c) compress the file before transmission.

    The easiest way to limit the file size for response is to write a little control logic in your servlet that checks the file's size:


    File file = new File("[location-of-xml-file");
    int fileSize = file.length(); // Size in bytes
  3. HTTP responses...[ Go to top ]

    The HTTP 1.1 protocol does not have any limitations.

    Responses can be sent using HTTP 1.1 chunked encoding.