I'll run through section by section ...

6.1 Buffering

  ServletResponse.setBufferSize()

   "This method must be called before any content is
    written using a ServletOutputStream or Writer. If
    any content has been written, this method must
    throw an IllegalStateException"

   Suppose I've written to the OutputStream, but not
   enough to trigger a commit. I then call reset(). If
   I now call setBufferSize() the quoted clause requires
   that an IllegalStateException be thrown. But that
   should be unecessary in this scenario.

6.2 Headers

   setHeader() and addHeader() allow arbitrary HTTP
   headers to be added to the response. A servlet
   container may wish to reject some of those headers
   if they're inappropriate ie.,

     addHeader("Connection", "Keep-Alive");

   would be inappropriate if the container was going to
   be closing the connection (if the request contained
   a 'Connection: close' for example).

   Any of the following or similar are likely to be
   bogus,

     addHeader("Connection", "Server");
     addHeader("Upgrade", "TLS/1.0");

   It should either be documented that a container
   might throw an exception if an inappropriate header
   is set (my preferred option), or that some headers
   might be silently modified or removed if required for
   the proper operation of the container.

6.4 Internationalization

   "For maximum benefit, the setLocale method should
    be called by the developer before the getWriter
    method of the ServletResponse interface is called.
    This will ensure that the returned PrintWriter is
    configured appropriately for the target Locale."

  This presupposes that there's a defined mapping from
  locales to character encodings. There isn't.

6.5 Closure of Response Object

  The response object is considered to be closed,

   "When the amount of content specified in the
    setContentLength method of the response has been
    written to the response"

   Consider the following,

     res.setContentLength(512);
     out.write(... 1024 bytes ...);

   The spec is silent on whether the content-length-
   overrunning write should throw an exception (my
   preferred option) or silently truncate the output.

   Also, consider the following sequence of calls,

     res.setBufferSize(2048);
     out.write(... 1024 bytes ...);
     res.setContentLength(512);
     res.flushBuffer();

   What should happen here? The buffer has been set
   sufficiently large that the content-length-
   overrunning write will not cause a commit, but the
   subsequent setContentLength() conflicts with the
   number of bytes already written to the response
   buffer. There are several options here,

   1. Silently truncate the buffer. Yuck.
   2. Have setContentLength() throw an exception.
   3. Require that setContentLength() either be called
      before any output is written or not at all. If
      setContentLength isn't called, then either
      the content-length would be inferred from the
      size of the output (if it fits in the buffer) or
      chunked transfer encoding would be used (HTTP1.1)
      or the connection would be closed (HTTP1.0).
      This would be my preferred option.

8.3 Include

   "The included servlet cannot set headers or call
    any method that affects the headers of the response.
    Any attempt to do so should be ignored"

   An IllegalStateException would be better. Silently
   ignoring explicit programmer requests is never a
   good idea.

Cheers,


Miles

--
Miles Sabin                          Cromwell Media
Internet Systems Architect           5/6 Glenthorne Mews
+44 (0)181 410 2230                  London, W6 0LJ
[EMAIL PROTECTED]           England

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to