sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject svn commit: r850062 - in /websites/staging/sling/trunk/content: ./ documentation/the-sling-engine/errorhandling.html
Date Sat, 09 Feb 2013 21:48:55 GMT
Author: buildbot
Date: Sat Feb  9 21:48:54 2013
New Revision: 850062

Staging update by buildbot for sling

    websites/staging/sling/trunk/content/   (props changed)

Propchange: websites/staging/sling/trunk/content/
--- cms:source-revision (original)
+++ cms:source-revision Sat Feb  9 21:48:54 2013
@@ -1 +1 @@

Modified: websites/staging/sling/trunk/content/documentation/the-sling-engine/errorhandling.html
--- websites/staging/sling/trunk/content/documentation/the-sling-engine/errorhandling.html
+++ websites/staging/sling/trunk/content/documentation/the-sling-engine/errorhandling.html
Sat Feb  9 21:48:54 2013
@@ -89,6 +89,31 @@
       <p>The Sling Engine includes support for handling uncaught <code>Throwable</code>
as well as rendering custom HTTP status code pages. This is implemented by expecting a (single)
<code></code> service to which handling
of uncaught <code>Throwable</code> and HTTP status responses are delegated.</p>
 <p>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.</p>
 <p>This page provides more information on how error handler scripts are selected and
what is provided out of the box.</p>
+<div class="toc">
+<li><a href="#resetting-the-response">Resetting the Response</a></li>
+<li><a href="#http-status-codes">HTTP Status Codes</a></li>
+<li><a href="#uncaught-throwables">Uncaught Throwables</a></li>
+<li><a href="#default-handler">Default Handler</a></li>
+<h2 id="resetting-the-response">Resetting the Response</h2>
+<p>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:</p>
+<li>Check whether the response has already been committed</li>
+<li>If the response has been committed:<ul>
+<li>Reset the response</li>
+<li>Set the status code (use <code>HttpServletResponse.setStatus</code>)</li>
+<li>Set the response content type and character encoding (provided text data is sent
+<li>If the response has already been committed:<ul>
+<li>Do not try to reset since this would cause an <code>IllegalStateException</code>.
Also the writer may not be available.</li>
+<li>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.</li>
 <h2 id="http-status-codes">HTTP Status Codes</h2>
 <p>The Sling engine implements the <code>HttpServletResponse.sendError</code>
methods by calling the <code>ErrorHandler.handleError(int status, String message, SlingHttpServletRequest
request, SlingHttpServletResponse response)</code> method.</p>
 <p>The Servlet Resolver bundle implementation looks up a script to handle the status
code as follows:</p>
@@ -116,7 +141,7 @@ To register a catch-all handler for any 
 <p>Starting with Sling Servlet Resolver version 2.0.10 the default error handler servlet
is looked up using the string <code>default</code> as the request extension and
the provided default servlet is registered as <code>&lt;prefix&gt;/sling/servlet/errorhandler/default.servlet</code>
where <prefix> is the last entry in the resource resolver search path, <code>/libs</code>
by default.</p>
 <p>Thus to overwrite the default error handler servlet provide a servlet or script
for the <code>default</code> extension, for example <code>/apps/sling/servlet/errorhandler/default.groovy</code>.</p>
       <div class="timestamp" style="margin-top: 30px; font-size: 80%; text-align: right;">
-        Rev. 1341376 by fmeschbe on Tue, 22 May 2012 09:41:06 +0000
+        Rev. 1444445 by fmeschbe on Sat, 9 Feb 2013 21:48:40 +0000
       <div class="trademarkFooter"> 
         Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project

View raw message