sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject svn commit: r1444445 - /sling/site/trunk/content/documentation/the-sling-engine/errorhandling.mdtext
Date Sat, 09 Feb 2013 21:48:40 GMT
Author: fmeschbe
Date: Sat Feb  9 21:48:40 2013
New Revision: 1444445

+= section on resetting the response


Modified: sling/site/trunk/content/documentation/the-sling-engine/errorhandling.mdtext
--- sling/site/trunk/content/documentation/the-sling-engine/errorhandling.mdtext (original)
+++ sling/site/trunk/content/documentation/the-sling-engine/errorhandling.mdtext Sat Feb 
9 21:48:40 2013
@@ -1,12 +1,27 @@
 Title: Errorhandling
 The Sling Engine includes support for handling uncaught `Throwable` as well as rendering
custom HTTP status code pages. This is implemented by expecting a (single) ``
service to which handling of uncaught `Throwable` and HTTP status responses are delegated.
 The Sling Servlet Resolver bundle implements this interface by providing an elaborate mechanism
to find the correct error handling script or servlet using the same algorithms as are used
to select the scripts or servlets to handle regular requests.
 This page provides more information on how error handler scripts are selected and what is
provided out of the box.
+## Resetting the Response
+Errorhandler scripts and servlets are script with the current response. Before setting
+the status and writing to the response such handlers should do the following:
+* Check whether the response has already been committed
+* If the response has been committed:
+    * Reset the response
+    * Set the status code (use `HttpServletResponse.setStatus`)
+    * Set the response content type and character encoding (provided text data is sent back)
+* If the response has already been committed:
+    * Do not try to reset since this would cause an `IllegalStateException`. Also the writer
may not be available.
+    * The best that might be done in this case is just log a message at warning or error
level along with information about the failure.
 ## HTTP Status Codes

View raw message