incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r813967 [13/16] - /websites/staging/sling/trunk/content/
Date Sun, 22 Apr 2012 16:52:31 GMT
Added: websites/staging/sling/trunk/content/request-processing.html
==============================================================================
--- websites/staging/sling/trunk/content/request-processing.html (added)
+++ websites/staging/sling/trunk/content/request-processing.html Sun Apr 22 16:52:28 2012
@@ -0,0 +1,376 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE- 2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+  <head>
+    <title>Apache Sling - Request Processing</title>
+    <link rel="stylesheet" href="http://sling.apache.org/site/media.data/site.css" type="text/css" media="all">
+    <link rel="icon" href="http://sling.apache.org/site/media.data/favicon.ico">
+    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
+  </head>
+  <body>
+    <div class="title">
+      <div class="logo">
+        <a href="http://sling.apache.org/site/index.html">
+          <img border="0" alt="Apache Sling" src="http://sling.apache.org/site/media.data/logo.png">
+        </a>
+      </div>
+      <div class="header">
+        <a href="http://www.apache.org/">
+          <img border="0" alt="Apache" src="http://sling.apache.org/site/media.data/apache.png">
+        </a>
+      </div>
+    </div>
+    
+    <div class="menu"> 
+      <h1 id="documentation">Documentation</h1>
+<ul>
+<li><a href="getting-started.html">Getting Started</a></li>
+<li><a href="the-sling-engine.html">The Sling Engine</a></li>
+<li><a href="development.html">Development</a></li>
+<li><a href="bundles.html">Bundles</a></li>
+<li><a href="tutorials-&amp;-how-tos.html">Tutorials &amp; How-Tos</a></li>
+<li><a href="configuration.html">Configuration</a></li>
+<li><a href="http://sling.apache.org/apidocs/sling5/index.html">API docs</a></li>
+<li><a href="http://s.apache.org/sling.wiki">Wiki</a></li>
+<li><a href="http://s.apache.org/sling.faq">FAQ</a></li>
+</ul>
+<h1 id="project-info">Project info</h1>
+<ul>
+<li><a href="http://sling.apache.org/site/downloads.cgi">Downloads</a></li>
+<li><a href="http://www.apache.org/licenses/">License</a></li>
+<li><a href="contributing.html">Contributing</a></li>
+<li><a href="news.html">News</a></li>
+<li><a href="links.html">Links</a></li>
+<li><a href="project-information.html">Project Information</a></li>
+<li><a href="https://issues.apache.org/jira/browse/SLING">Issue Tracker</a></li>
+<li><a href="http://svn.apache.org/viewvc/sling/trunk">Browse Source Repository</a></li>
+<li><a href="http://www.apache.org/security/">Security</a></li>
+</ul>
+<h1 id="sponsorship">Sponsorship</h1>
+<ul>
+<li><a href="http://www.apache.org/foundation/thanks.html">Thanks</a></li>
+<li><a href="http://www.apache.org/foundation/sponsorship.html">Become a Sponsor</a></li>
+<li><a href="http://www.apache.org/foundation/buy_stuff.html">Buy Stuff</a></li>
+</ul>
+<iframe 
+    src="http://www.apache.org/ads/button.html"
+    style="border-width:0; float: left" frameborder="0" 
+    scrolling="no"
+    width="135" 
+    height="135">
+</iframe>
+    </div>
+    
+    <div class="main">
+      <div class="breadcrump" style="font-size: 80%;">
+		(TODO: breadcrumb here)
+      </div>
+      <h1 class="title">Request Processing</h1>
+      <div>
+	    <p><a name="RequestProcessing-HTTPRequestProcessing"></a></p>
+<h1 id="http-request-processing">HTTP Request Processing</h1>
+<p>{note:title=Page Status}
+2008-02-13: this page is <em>out of sync</em> with the current codebase, needs to
+be reviewed and updated.
+{note}</p>
+<p>One of the core problems towards understanding how Sling works is knowing
+how a Client Request is processed by Sling. This page describes the flow of
+processing requests inside Sling.</p>
+<p><a name="RequestProcessing-CoreRequestProcessing"></a></p>
+<h2 id="core-request-processing">Core Request Processing</h2>
+<p>The HTTP request enters Sling in the
+{{org.apache.sling.core.ComponentRequestHandlerImpl.service(ServletRequest
+req, ServletResponse res)}} method as the <em>ComponentRequestHandlerImpl</em>
+is registered as the Servlet handling HTTP requests. This method sets up
+the initial <em>ComponentRequest</em> and <em>ComponentResponse</em> objects and
+hands the request over to the first <em>ComponentFilterChain</em>. This first
+filter chain calls all <em>ComponentFilter</em> instances registered as request
+level filters. After processing all filters in the request level filter
+chain, the request is handed over to the second <em>ComponentFilterChain</em>
+which calls all <em>ComponentFilter</em> instances registered as component level
+filters. At the end of the second filter chain the <em>service</em> method of
+the actual <em>Component</em> to which the request resolved is called.</p>
+<p>As the component is now processing the request, it may decide to dispatch
+the request to some other content such as for example a paragraph system or
+navigation component. To do this, the component will call the
+<em>RequestDispatcher.include</em> method. If the request dispatcher dispatches
+to a <em>Content</em> object Sling will hand the dispatch request over to the
+component level filter chain, which at the end will call the <em>service</em>
+method for the <em>Content</em> object to dispatched to. This process may be
+repeated at the component's discretion only limited by processing resources
+such as available memory.</p>
+<p>As can be seen Sling itself is absed on the Component API
+<em>ComponentFilter</em> mechanism. As such Sling provides and uses the
+following filters in the Sling Core bundle:</p>
+<p>{table:class=confluenceTable}
+{tr}{th:colspan=2|class=confluenceTh} Request Level Filters {th}{tr}
+{tr}{td:class=confluenceTd} <em>ErrorHandlerFilter</em>
+{td}{td:class=confluenceTd} Handles exceptions thrown while processing the
+request as well implements the <em>ComponentResponse.sendError()</em> method
+{td}{tr}
+{tr}{td:class=confluenceTd} <em>AuthenticationFilter</em>
+{td}{td:class=confluenceTd} Implements authentication for the request and
+provides the JCR Session of the request {td}{tr}
+{tr}{td:class=confluenceTd} <em>BurstCacheFilter</em>
+{td}{td:class=confluenceTd} Checks whether the request may be handled by
+cached response data {td}{tr}
+{tr}{td:class=confluenceTd} <em>LocaleResolverFilter</em>
+{td}{td:class=confluenceTd} Provides information on the <em>Locale</em> to be
+used for request processing. This filter implements the
+<em>ComponentRequest.getLocale()</em> method {td}{tr}
+{tr}{td:class=confluenceTd} <em>ThemeResolverFilter</em>
+{td}{td:class=confluenceTd} Provides the <em>Theme</em> for the request. The
+theme is provided as a request attribute {td}{tr}
+{tr}{td:class=confluenceTd} <em>URLMapperFilter</em> {td}{td:class=confluenceTd}
+Resolves the request URL to a JCR Node which may be mapped into a
+<em>Content</em> object {td}{tr}
+{tr}{td:class=confluenceTd} <em>ZipFilter</em> {td}{td:class=confluenceTd}
+Sample filter showing how the request response might be compressed
+according to the <em>Accept-Encoding</em> request header. This filter is not
+enabled by default. {td}{tr}
+{table}</p>
+<p>Deducing from these lists of filters, the actual request processing can be
+refined into the following steps:</p>
+<ol>
+<li>Extract user authentication information and acquire the JCR session to
+access content. If the request has no user authentication data the such
+data may be requested from the user (for example by sending a HTTP 401
+status) or an anonymous repository session might be acquired.</li>
+<li>Check whether the request may be handled by data stored in the cache.
+If the request is cacheable and a cache entry exists for the request URL,
+the request data is returned to the client and request processing may
+terminate. Otherwise request processing will continue and optionally ensure
+that any response data is entered into the cache. Of course, if the request
+is not cacheable, for example because there are request parameters, or if
+any of the <em>Component</em> instances called during request processing decide
+to signal non-cacheability for whatever reason, the response data will of
+course not cached.</li>
+<li>Extract the <em>java.util.Locale</em> from the request such that further
+processing may use properly translated messages. By default, the locale of
+the underlying Servlet request is used as the request locale. Other
+possibilities would be to use special cookies or some locale encoding in
+the path.</li>
+<li>Find the theme (or skin) to use to render the response. This step will
+add a <em>org.apache.sling.theme.Theme</em> object as a request parameter, which
+may be used by <em>Component</em>s to decide on specific rendering. For example,
+the theme may encapsulate information on the CSS to use for responses
+rendered as HTML.</li>
+<li>Resolve the request URL into a <em>Content</em> object.</li>
+</ol>
+<p>The default request level filter chain setup ends with finding the
+<em>Content</em> object requested by the request URL. After having found this
+object, the request is handed over to the component level filter chain,
+which is concerned with handling filtering on a single <em>Content</em>
+instance. As such, the component level filter chain is used for each
+<em>Content</em> object which is to be serviced either on behalf of the HTTP
+request or on behalf of request dispatcher. Thus the component level filter
+chain will generally called multiple times during a single request.</p>
+<p>{table:class=confluenceTable}
+{tr}{th:colspan=2|class=confluenceTh} Component Level Filters {th}{tr}
+{tr}{td:class=confluenceTd} <em>CacheFilter</em> {td}{td:class=confluenceTd}
+Checks whether the request to the current <em>Content</em> object may be handled
+by cached response data {td}{tr}
+{tr}{td:class=confluenceTd} <em>ComponentResolverFilter</em>
+{td}{td:class=confluenceTd} Resolves the component ID returned by the
+<em>Content.getComponentId()</em> method into a <em>Component</em> instances, which
+will be called to service the request {td}{tr}
+{table}</p>
+<p>Again, deducing from the list of filters, the following steps are taking to
+service a given <em>Content</em> object:</p>
+<ol>
+<li>Check whether the <em>Content</em> object processing may be handled from
+the cache. Same as with request level cache handling, a cache entry may
+exist for a single <em>Content</em> instance depending on whether the request is
+cacheable at all and on whether a cache entry exists. If a cache entry
+exists and may be used, the response data is simply spooled into the
+response and component level processing terminates for the <em>Content</em>
+object. Otherwise processing continues and may optionally lead to a new
+cache entry for the <em>Content</em> object to be reused later.</li>
+<li>Resolve the component ID returned by the <em>Content.getComponentId()</em>
+method into a <em>Component</em> object. Of course it is an error, if the
+component ID cannot be mapped into a <em>Component</em> object.</li>
+</ol>
+<p>After resolving the <em>Component</em> object default component filter chain
+terminates and control is handed over to the <em>service</em> method of the
+<em>Component</em> object resolved in the last step. At the discretion of the
+component request dispatchers may now be acquired to render other
+<em>Content</em> objects. In this case the component level filter chain is
+simply kicked of again resulting in the <em>service</em> method of another
+<em>Component</em> being called. And so forth.</p>
+<p><a name="RequestProcessing-ResolvingContent"></a></p>
+<h2 id="resolving-content">Resolving Content</h2>
+<p>As we have seen, the last step in the request level filter chain is the
+resolution of the request URL into a <em>Content</em> object. The URL Mapper
+Filter implementing this resolution uses an instance of the
+<em>org.apache.sling.content.ContentMapper</em> interface which is acquired by
+calling the <em>org.apache.sling.content.jcr.JcrContentManagerFactory</em> with
+the repository session acquired by the authentication filter.</p>
+<p>The URL Mapper filter then tries to apply fixed mappings from request URL
+to destination paths to support shortcut URLs. For example the root path
+<em>/</em> may be mapped into the default landing page at <em>/default/home</em>. The
+list of such mappings is configurable through the Configuration Admin
+Service.</p>
+<p>Next the URL Mapper tries to apply prefix matching patterns. A list of
+patterns is iterated checking whether the prefix applies and, if so,
+replacing the prefix with another prefix and trying to resolve the result.
+This functionality enables relocation of a subtree of the repository. For
+example, all requests whose prefix is <em>/here</em> might be remapped with the
+new prefix <em>/content/there</em>. The result  of this remapping is then
+resolved.</p>
+<p>Resolution (currently) takes place on the last path segment of the request
+URL containing at least one dot. Parts of that segment are cut off after
+dots until no more dots exist in the URL. For each resulting substring, the
+<em>ContentManager.load(String)</em> method is called. This processing
+terminates if a <em>Content</em> object is found or if there is nothing to cut
+off any more.</p>
+<p>This resolution is very simple and straight forwards. Future development
+may add support for the following features:</p>
+<ul>
+<li><em>Vanity URLs</em> - Map the request URL according to the <em>Host</em> request
+header.</li>
+<li><em>Dynamic Mapping</em> - Add support for a set of variables in path and/or
+prefix mapping. For example, a prefix mapping  may contain the string
+<em>/content/${lang}/${user</em>} resulting in resolving a prefix according to
+the language of the current locale and the name of the authenticated used.</li>
+</ul>
+<p><a name="RequestProcessing-RegisteringComponents"></a></p>
+<h2 id="registering-components">Registering Components</h2>
+<p>The last step of the component level filter chain is resolving the
+<em>Component</em> from the component ID of the <em>Content</em> object. Sling
+implements this resolution by making use of the OSGi service registry. That
+is, each component is to be registered as a service with the name
+<em>org.apache.sling.component.Component</em>. The <em>ComponentResolverFilter</em>
+is listening for these components and registers them internally in a map
+indexed by the IDs of the component as returned by the
+<em>Component.getId()</em> method.</p>
+<p>When a component has to be resolved, the component ID returned by the
+<em>Content</em> object is simply looked up in the component map. If found, that
+component is used. Otherwise a fall back algorithm is applied which is
+described on the <a href="default-mapping-and-rendering.html">Default Content Mapping and Request Rendering</a>
+ page.</p>
+<p><a name="RequestProcessing-ReqisteringFilters"></a></p>
+<h2 id="reqistering-filters">Reqistering Filters</h2>
+<p>Just as <em>Component</em> instances used by Sling are expected to be registered
+as OSGi services, the <em>ComponentFilter</em>s to be 
+used have to be registered as services under the name
+<em>org.apache.sling.component.ComponentFilter</em>. Sling picks up all
+registered component filters and adds them to the respective filter chains.</p>
+<p>Service properties set upon registration of the filter define the chain to
+which the filter belongs and the order in which the filters should be
+processed:</p>
+<table>
+<tr><th> Property </th><th> Description </th></tr>
+<tr><td> *filter.scope* </td><td> Defines the chain to which the filter is added.
+Supported values are *component* for component level filters and
+*request* for request level filters. If this property is missing or set
+to an unknown value the filter is added to the request level filter chain.
+</td></tr>
+<tr><td> *filter.order* </td><td> Defines the weight of the filter to resolve the
+processing order. This property must be an *java.lang.Integer*. If not
+set or not an *Integer* the order defaults to *Integer.MAX_VALUE*. The
+lower the order number the earlier in the filter chain will the filter be
+inserted. If two filters are registered with the same order value, the
+filter with the lower *service.id* value is called first. </td></tr>
+</table>
+
+<p><a name="RequestProcessing-ContentisaJavaObject"></a></p>
+<h2 id="content-is-a-java-object">Content is a Java Object</h2>
+<p>It is crucial to understand that <em>Content</em> is an interface and the
+request processor of Sling does not actually care, how the <em>Content</em>
+instance comes to live as long as the is such an object and there is a
+<em>Component</em> instance capable of servicing the <em>Content</em> object.</p>
+<p>By default Sling uses the <em>URL Mapper</em> to resolve the request URL into a
+<em>Content</em> object. When a <em>Component</em> is tasked with servicing a
+<em>Content</em> object it usually uses the <em>ComponentRequestDispatcher</em> to
+ask Sling to service another content object generally identified by a
+(relative or absolute) path to a JCR Repository Node from which the
+<em>Content</em> object is loaded.</p>
+<p>But instead of having Sling resolve a path into a <em>Content</em> object the
+component may just as well create a <em>Content</em> object and hand it over to
+the <em>ComponentRequestDispatcher</em> for service. Consider a request which is
+handled by a <em>PageComponent</em>. This component has to draw a navigation
+tree somewhere in the response. So the component could of course insist on
+having a <em>navigation</em> child node to dispatch rendering to as follows:</p>
+<div class="codehilite"><pre><span class="n">RequestDispatcher</span> <span class="n">rd</span> <span class="o">=</span> <span class="n">request</span><span class="o">.</span><span class="n">getRequestDispatcher</span><span class="p">(</span><span class="s">&quot;navigation&quot;</span><span class="p">);</span>
+<span class="n">rd</span><span class="o">.</span><span class="n">include</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="n">response</span><span class="p">);</span>
+</pre></div>
+
+
+<p>What happens, though, if there is no <em>navigation</em> child node ? Probably,
+the request will fail with some error status. Of course the component could
+be more clever and do:</p>
+<div class="codehilite"><pre><span class="n">Content</span> <span class="n">navigation</span> <span class="o">=</span> <span class="n">request</span><span class="o">.</span><span class="n">getContent</span><span class="p">(</span><span class="s">&quot;navigation&quot;</span><span class="p">);</span>
+<span class="k">if</span> <span class="p">(</span><span class="n">navigation</span> <span class="o">!=</span> <span class="n">null</span><span class="p">)</span> <span class="p">{</span>
+    <span class="n">RequestDispatcher</span> <span class="n">rd</span> <span class="o">=</span> <span class="n">request</span><span class="o">.</span><span class="n">getRequestDispatcher</span><span class="p">(</span><span class="n">navigation</span><span class="p">);</span>
+    <span class="n">rd</span><span class="o">.</span><span class="n">include</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="n">response</span><span class="p">);</span>
+<span class="p">}</span>
+</pre></div>
+
+
+<p>Still, if the <em>navigation</em> child node does not exist, there is no
+navigation drawn; at least there will be now error. Since Sling does not
+actually care, how a <em>Content</em> object comes to live, the component could
+do the following:</p>
+<div class="codehilite"><pre><span class="n">Content</span> <span class="n">navigation</span> <span class="o">=</span> <span class="k">new</span> <span class="n">Content</span><span class="p">()</span> <span class="p">{</span>
+    <span class="n">public</span> <span class="n">String</span> <span class="n">getPath</span><span class="p">()</span> <span class="p">{</span>
+    <span class="k">return</span> <span class="n">request</span><span class="o">.</span><span class="n">getContent</span><span class="p">()</span><span class="o">.</span><span class="n">getPath</span><span class="p">()</span> <span class="o">+</span> <span class="s">&quot;/navigation&quot;</span><span class="p">;</span>
+    <span class="p">}</span>
+    <span class="n">public</span> <span class="n">String</span> <span class="n">getComponentId</span><span class="p">()</span> <span class="p">{</span>
+    <span class="k">return</span> <span class="n">NavigationComponent</span><span class="o">.</span><span class="n">getClass</span><span class="p">()</span><span class="o">.</span><span class="n">getName</span><span class="p">();</span>
+    <span class="p">}</span>
+<span class="p">}</span>
+
+<span class="n">RequestDispatcher</span> <span class="n">rd</span> <span class="o">=</span> <span class="n">request</span><span class="o">.</span><span class="n">getRequestDispatcher</span><span class="p">(</span><span class="n">navigation</span><span class="p">);</span>
+<span class="n">rd</span><span class="o">.</span><span class="n">include</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="n">response</span><span class="p">);</span>
+</pre></div>
+
+
+<p>Of course, the page component now has to have knowledge about the actual
+<em>Component</em> to use.</p>
+<p>Finally, as a further enhancement, the Component might even decide to first
+check for a <em>navigation</em> child node. If such a node does not exist the
+navigation <em>Content</em> object is just created:</p>
+<div class="codehilite"><pre><span class="n">Content</span> <span class="n">navigation</span> <span class="o">=</span> <span class="n">request</span><span class="o">.</span><span class="n">getContent</span><span class="p">(</span><span class="s">&quot;navigation&quot;</span><span class="p">);</span>
+<span class="k">if</span> <span class="p">(</span><span class="n">navigation</span> <span class="o">==</span> <span class="n">null</span><span class="p">)</span> <span class="p">{</span>
+    <span class="n">navigation</span> <span class="o">=</span> <span class="k">new</span> <span class="n">Content</span><span class="p">()</span> <span class="p">{</span>
+    <span class="n">public</span> <span class="n">String</span> <span class="n">getPath</span><span class="p">()</span> <span class="p">{</span>
+        <span class="k">return</span> <span class="n">request</span><span class="o">.</span><span class="n">getContent</span><span class="p">()</span><span class="o">.</span><span class="n">getPath</span><span class="p">()</span> <span class="o">+</span> <span class="s">&quot;/navigation&quot;</span><span class="p">;</span>
+    <span class="p">}</span>
+    <span class="n">public</span> <span class="n">String</span> <span class="n">getComponentId</span><span class="p">()</span> <span class="p">{</span>
+        <span class="k">return</span> <span class="n">NavigationComponent</span><span class="o">.</span><span class="n">getClass</span><span class="p">()</span><span class="o">.</span><span class="n">getName</span><span class="p">();</span>
+    <span class="p">}</span>
+    <span class="p">}</span>
+<span class="p">}</span>
+
+<span class="n">RequestDispatcher</span> <span class="n">rd</span> <span class="o">=</span> <span class="n">request</span><span class="o">.</span><span class="n">getRequestDispatcher</span><span class="p">(</span><span class="n">navigation</span><span class="p">);</span>
+<span class="n">rd</span><span class="o">.</span><span class="n">include</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="n">response</span><span class="p">);</span>
+</pre></div>
+
+
+<p>This could for example be used to fall back to a default navigation setup
+while providing for specialized navigation configuration in an optional
+<em>navigation</em> child node.</p>
+      </div>
+    </div>
+    
+    <div class="trademarkFooter"> 
+		Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.
+	</div>
+  </body>
+</html>

Added: websites/staging/sling/trunk/content/resources.html
==============================================================================
--- websites/staging/sling/trunk/content/resources.html (added)
+++ websites/staging/sling/trunk/content/resources.html Sun Apr 22 16:52:28 2012
@@ -0,0 +1,271 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE- 2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+  <head>
+    <title>Apache Sling - Resources</title>
+    <link rel="stylesheet" href="http://sling.apache.org/site/media.data/site.css" type="text/css" media="all">
+    <link rel="icon" href="http://sling.apache.org/site/media.data/favicon.ico">
+    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
+  </head>
+  <body>
+    <div class="title">
+      <div class="logo">
+        <a href="http://sling.apache.org/site/index.html">
+          <img border="0" alt="Apache Sling" src="http://sling.apache.org/site/media.data/logo.png">
+        </a>
+      </div>
+      <div class="header">
+        <a href="http://www.apache.org/">
+          <img border="0" alt="Apache" src="http://sling.apache.org/site/media.data/apache.png">
+        </a>
+      </div>
+    </div>
+    
+    <div class="menu"> 
+      <h1 id="documentation">Documentation</h1>
+<ul>
+<li><a href="getting-started.html">Getting Started</a></li>
+<li><a href="the-sling-engine.html">The Sling Engine</a></li>
+<li><a href="development.html">Development</a></li>
+<li><a href="bundles.html">Bundles</a></li>
+<li><a href="tutorials-&amp;-how-tos.html">Tutorials &amp; How-Tos</a></li>
+<li><a href="configuration.html">Configuration</a></li>
+<li><a href="http://sling.apache.org/apidocs/sling5/index.html">API docs</a></li>
+<li><a href="http://s.apache.org/sling.wiki">Wiki</a></li>
+<li><a href="http://s.apache.org/sling.faq">FAQ</a></li>
+</ul>
+<h1 id="project-info">Project info</h1>
+<ul>
+<li><a href="http://sling.apache.org/site/downloads.cgi">Downloads</a></li>
+<li><a href="http://www.apache.org/licenses/">License</a></li>
+<li><a href="contributing.html">Contributing</a></li>
+<li><a href="news.html">News</a></li>
+<li><a href="links.html">Links</a></li>
+<li><a href="project-information.html">Project Information</a></li>
+<li><a href="https://issues.apache.org/jira/browse/SLING">Issue Tracker</a></li>
+<li><a href="http://svn.apache.org/viewvc/sling/trunk">Browse Source Repository</a></li>
+<li><a href="http://www.apache.org/security/">Security</a></li>
+</ul>
+<h1 id="sponsorship">Sponsorship</h1>
+<ul>
+<li><a href="http://www.apache.org/foundation/thanks.html">Thanks</a></li>
+<li><a href="http://www.apache.org/foundation/sponsorship.html">Become a Sponsor</a></li>
+<li><a href="http://www.apache.org/foundation/buy_stuff.html">Buy Stuff</a></li>
+</ul>
+<iframe 
+    src="http://www.apache.org/ads/button.html"
+    style="border-width:0; float: left" frameborder="0" 
+    scrolling="no"
+    width="135" 
+    height="135">
+</iframe>
+    </div>
+    
+    <div class="main">
+      <div class="breadcrump" style="font-size: 80%;">
+		(TODO: breadcrumb here)
+      </div>
+      <h1 class="title">Resources</h1>
+      <div>
+	    <p><a name="Resources-Resources"></a></p>
+<h1 id="resources">Resources</h1>
+<p>{toc:minLevel=2}</p>
+<p><a name="Resources-WhatisaResource"></a></p>
+<h2 id="what-is-a-resource">What is a Resource</h2>
+<p>The Resource is one of the central parts of Sling. Extending from JCR's
+<em>Everything is Content</em>, Sling assumes <em>Everthing is a Resource</em>. Thus
+Sling is maintaining a virtual tree of resources, which is a merger of the
+actual contents in the JCR Repository and resources provided by so called
+resource providers. By doing this Sling fits very well in the paradigma of
+the REST architecture.</p>
+<p><a name="Resources-HowtogetaResource"></a></p>
+<h2 id="how-to-get-a-resource">How to get a Resource</h2>
+<p>To get at Resources, you need a <em>ResourceResolver</em>. This interface
+defines four kinds of methods to access resources:
+<em> Absolute Path Mapping Resource Resolution: The
+</em>resolve(HttpServletRequest, String)<em> and </em>resolve(String)<em> methods are
+called to apply some implementation specific path matching algorithm to
+find a Resource. These methods are mainly used to map external paths - such
+as path components of request URLs - to Resources. To support creating
+external paths usable in an URL a third method </em>map(String)<em> is defined,
+which allows for round-tripping.
+</em> Absolute or Relative Path Resolution (including search path): The
+<em>getResource(String path)</em> and {{getResource(Resource base, String
+path)}} methods may be used to access a resource with an absolute path
+directly. If it can't be found the path is assumed to be relative and the
+search path retrieved from <em>getSearchPath()</em> is used to retrieve the
+resource. This mechanism is similar to resolving a programm with the
+<em>PATH</em> environment variable in your favourite operating system.
+<em> Resource Enumeration: To enumerate resources and thus iterate the
+resource tree, the </em>listChildren(Resource)<em> method may be used. This
+method returns an </em>Iterator<Resource><em> listing all resources whose path
+prefix is the path of the given Resource. This method will of course also
+cross boundaries of registered </em>ResourceProvider<em> instances to enable
+iterating the complete resource tree.
+</em> Resource Querying: Querying resources is currently only supported for JCR
+Resources through the <em>findResources(String query, String language)</em> and
+<em>queryResources(String query, String language)</em> methods. For more
+information see the section on <a href="#querying_resources.html">Querying_Resources</a>
+ below.</p>
+<p><a name="Resources-AbsolutePathMapping"></a></p>
+<h3 id="absolute-path-mapping">Absolute Path Mapping</h3>
+<p>As has been said, the absolute path mapping methods
+<em>resolve(HttpServletRequest, String)</em> and <em>resolve(String)</em> apply some
+implementation specific path matching algorithm to find a Resource. The
+difference between the two methods is that the former may take more
+properties of the <em>HttpServletRequest</em> into account when resolving the
+Resoure, while the latter just has an absolute path to work on.</p>
+<p>The general algorithm of the two methods is as follows:
+1. Call <em>HttpServletRequest.getScheme(), .getServerName(), getServerPort</em> to get an absolute path out of the request URL: [scheme](scheme.html)
+/[host].[port][path] (<em>resolve(HttpServletRequest, String)</em> method
+only, which)
+1. Check whether any virtual path matches the absolute path. If such a match
+exists, the next step is entered with the match.
+1. Apply a list of mappings in order to create a mapped path. The first
+mapped path resolving to a Resource is assumed success and the Resource
+found is returned.
+1. If no mapping created a mapped path addressing an existing Resource, the
+method fails and returns:</p>
+<ul>
+<li>The <em>resolve(String)</em> and <em>resolve(HttpServletRequest,String)</em>
+methods return a <em>NonExistingResource</em></li>
+<li>The <em>getResource(String path)</em> and {{getResource(Resource base, String
+path)}} methods return null</li>
+</ul>
+<p>The virtual path mapping may be used to create shortcut URLs for otherwise
+long and complicated URLs. An example of such an URL might be the main
+administrative page of a CMS system. So, administrators may access the root
+of the web application and directed to the main administrative page.</p>
+<p>The path mapping functionality may be used to hide internal resource
+organization from the request URL space. For example to better control the
+structure of your repository, you might decide to store all accessible data
+inside a <em>/content</em> subtree. To hide this fact from the users, a mapping
+may be defined to prefix all incoming paths with <em>/content</em> to get at the
+actual Resource.</p>
+<p>The <em>map(String)</em> applies the path mapping algorithm in the reverse
+order. That is, first the path mappings are reversed and then any virtual
+mappings are checked. So, a path <em>/content/sample</em> might be mapped
+<em>/sample</em> to revers the <em>/content</em> prefixing. Or the main
+administrative page - say <em>/system/admin/main.html</em> - may be mapped to
+the virtual URL <em>/</em>.</p>
+<p><a name="Resources-RelativePathResolution"></a></p>
+<h3 id="relative-path-resolution">Relative Path Resolution</h3>
+<p>Sometimes it is required to resolve relative paths to Resources. An example
+of such a use case is Script and Servlet resolution which starts with a
+relative path consisting of the Resource type, optional selectors and the
+request extension or method name. By scanning a search path for these
+relative paths a system provided Resource may be overwritten with some user
+defined implementation.</p>
+<p>Consider for example, the system would provide a Servlet to render Resources of type <em>nt:file</em>. This Servlet would be registered under the path <em>/libs/nt/file/html</em>. For a certain web application, this default HTML rendering might not be appropriate, so a Script is created as <em>/apps/nt/file/html.jsp</em> with a customized HTML rendering. By defining the search path to be <em>[</em> <em><em>/apps{</em>}{</em>}<em>,</em> <em><em>/libs{</em></em>} <em>](</em>-<em><em>/apps{</em>}{</em>}<em>,</em>-<em><em>/libs{</em></em>}-<em>.html)
+</em> the Servlet resolver would call the
+<em>ResourceResolver.getResource(String)</em> method with the relative path
+<em>nt/file/html</em> and be provided with the first matching resource -
+<em>/apps/nt/file/html.jsp</em> in this example.</p>
+<p>Of course the search path is not used for absolute path arguments.</p>
+<p><a name="Resources-QueryingResources"></a></p>
+<h3 id="querying-resources">Querying Resources</h3>
+<p>For convenience the <em>ResourceResolver</em> provides two Resource querying
+methods <em>findResources</em> and <em>queryResources</em> both methods take as
+arguments a JCR query string and a query language name. These parameters
+match the parameter definition of the {{QueryManager.createQuery(String
+statement, String language)}} method of the JCR API.</p>
+<p>The return value of these two methods differ in the use case:
+<em> </em>findResources<em> returns an </em>Iteratory<Resource><em> of all Resources
+matching the query. This method is comparable to calling </em>getNodes()<em> on
+the </em>QueryResult<em> returned from executing the JCR query.
+</em> <em>queryResources</em> returns an <em>Iterator<Map<String, Object>&gt;</em>. Each
+entry in the iterator is a <em>Map&lt;String, Object</em> representing a JCR result
+<em>Row</em> in the <em>RowIterator</em> returned from executing the JCR query. The
+map is indexed by the column name and the value of each entry is the value
+of the named column as a Java Object.</p>
+<p>These methods are convenience methods to more easily post queries to the
+repository and to handle results in very straight forward way using only
+standard Java functionality.</p>
+<p>Please note, that Resource querying is currently only supported for
+repository based Resources. These query methods are not reflected in the
+<em>ResourceProvider</em> interface used to inject non-repository Resources into
+the Resource tree.</p>
+<p><a name="Resources-ProvidingResources"></a></p>
+<h2 id="providing-resources">Providing Resources</h2>
+<p>The virtual Resource tree to which the the Resource accessor methods
+<em>resolve</em> and <em>getResource</em> provide access is implemented by a
+collection of registered <em>ResourceProvider</em> instances. The main Resource
+provider is of course the repository based <em>JcrResourceProvider</em> which
+supports Node and Property based resources. This Resource provider is
+always available in Sling. Further Resource providers may or may not exist.</p>
+<p>Each Resource provider is registered as an OSGi service with a required
+service registration property <em>provider.roots</em>. This is a multi-value
+String property listing the absolute paths Resource tree entries serving as
+roots to provided subtrees. For example, if a Resource provider is
+registered with the service registration property <em>provider.roots</em> set to
+<em>/some/root</em>, all paths starting with <em>/some/root</em> are first looked up in
+the given Resource Provider.</p>
+<p>When looking up a Resource in the registered Resource providers, the
+<em>ResourceResolver</em> applies a longest prefix matching algorithm to find
+the best match. For example consider three Resource provider registered as
+follows:
+<em> JCR Resource provider as </em>/<em>
+</em> Resource provider R1 as <em>/some</em>
+<em> Resource provider R2 as </em>/some/path*</p>
+<p>When accessing a Resource with path <em>/some/path/resource</em> the Resource
+provider <em>R2</em> is first asked. If that cannot provide the resource, Resource
+provider <em>R1</em> is asked and finally the JCR Resource provider is asked. The
+first Resource provider having a Resource with the requested path will be
+used.</p>
+<p><a name="Resources-JCR-basedResources"></a></p>
+<h3 id="jcr-based-resources">JCR-based Resources</h3>
+<p>JCR-based Resources are provided with the default <em>JcrResourceProvider</em>.
+This Resource provider is always available and is always asked last. That
+is Resources provided by other Resource providers may never be overruled by
+repository based Resources.</p>
+<p><a name="Resources-Bundle-basedResources"></a></p>
+<h3 id="bundle-based-resources">Bundle-based Resources</h3>
+<p>Resources may by provided by OSGi bundles. Providing bundles have a Bundle
+manifest header <em>Sling-Bundle-Resources</em> containing a list of absolute
+paths provided by the bundle. The path are separated by comma or whitespace
+(SP, TAB, VTAB, CR, LF).</p>
+<p>The <em>BundleResourceProvider</em> supporting bundle-based Resources provides
+directories as Resources of type <em>nt:folder</em> and files as Resources of
+type <em>nt:file</em>. This matches the default primary node types intended to
+be used for directories and files in JCR repositories. For details see <a href="slingxsite:bundle-resources-(extensions.bundleresource).html">Bundle Resource.</a></p>
+<p><a name="Resources-ServletResources"></a></p>
+<h3 id="servlet-resources">Servlet Resources</h3>
+<p>Servlet Resources are registered by the Servlet Resolver bundle for
+Servlets registered as OSGi services. See <a href="slingxsite:servlets.html">Servlet Resolution</a>
+ for information on how Servlet Resources are provided.</p>
+<p><a name="Resources-FileSystemResources"></a></p>
+<h3 id="file-system-resources">File System Resources</h3>
+<p>The Filesystem Resource Provider provides access to the operating system's
+filesystem through the Sling ResourceResolver. Multiple locations may be
+mapped into the resource tree by configuring the filesystem location and
+the resource tree root path for each location to be mapped. For details see <a href="slingxsite:accessing-filesystem-resources-(extensions.fsresource).html">File System Resources</a>
+.</p>
+<p><a name="Resources-Wrap/DecorateResources"></a></p>
+<h2 id="wrapdecorate-resources">Wrap/Decorate Resources</h2>
+<p>The Sling API provides an easy way to wrap or decorate a resource before
+returning. Details see <a href="wrap-or-decorate-resources.html">Wrap or Decorate Resources</a>
+.</p>
+      </div>
+    </div>
+    
+    <div class="trademarkFooter"> 
+		Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.
+	</div>
+  </body>
+</html>

Added: websites/staging/sling/trunk/content/scriptengineintegration.html
==============================================================================
--- websites/staging/sling/trunk/content/scriptengineintegration.html (added)
+++ websites/staging/sling/trunk/content/scriptengineintegration.html Sun Apr 22 16:52:28 2012
@@ -0,0 +1,113 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE- 2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+  <head>
+    <title>Apache Sling - ScriptEngineIntegration</title>
+    <link rel="stylesheet" href="http://sling.apache.org/site/media.data/site.css" type="text/css" media="all">
+    <link rel="icon" href="http://sling.apache.org/site/media.data/favicon.ico">
+    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
+  </head>
+  <body>
+    <div class="title">
+      <div class="logo">
+        <a href="http://sling.apache.org/site/index.html">
+          <img border="0" alt="Apache Sling" src="http://sling.apache.org/site/media.data/logo.png">
+        </a>
+      </div>
+      <div class="header">
+        <a href="http://www.apache.org/">
+          <img border="0" alt="Apache" src="http://sling.apache.org/site/media.data/apache.png">
+        </a>
+      </div>
+    </div>
+    
+    <div class="menu"> 
+      <h1 id="documentation">Documentation</h1>
+<ul>
+<li><a href="getting-started.html">Getting Started</a></li>
+<li><a href="the-sling-engine.html">The Sling Engine</a></li>
+<li><a href="development.html">Development</a></li>
+<li><a href="bundles.html">Bundles</a></li>
+<li><a href="tutorials-&amp;-how-tos.html">Tutorials &amp; How-Tos</a></li>
+<li><a href="configuration.html">Configuration</a></li>
+<li><a href="http://sling.apache.org/apidocs/sling5/index.html">API docs</a></li>
+<li><a href="http://s.apache.org/sling.wiki">Wiki</a></li>
+<li><a href="http://s.apache.org/sling.faq">FAQ</a></li>
+</ul>
+<h1 id="project-info">Project info</h1>
+<ul>
+<li><a href="http://sling.apache.org/site/downloads.cgi">Downloads</a></li>
+<li><a href="http://www.apache.org/licenses/">License</a></li>
+<li><a href="contributing.html">Contributing</a></li>
+<li><a href="news.html">News</a></li>
+<li><a href="links.html">Links</a></li>
+<li><a href="project-information.html">Project Information</a></li>
+<li><a href="https://issues.apache.org/jira/browse/SLING">Issue Tracker</a></li>
+<li><a href="http://svn.apache.org/viewvc/sling/trunk">Browse Source Repository</a></li>
+<li><a href="http://www.apache.org/security/">Security</a></li>
+</ul>
+<h1 id="sponsorship">Sponsorship</h1>
+<ul>
+<li><a href="http://www.apache.org/foundation/thanks.html">Thanks</a></li>
+<li><a href="http://www.apache.org/foundation/sponsorship.html">Become a Sponsor</a></li>
+<li><a href="http://www.apache.org/foundation/buy_stuff.html">Buy Stuff</a></li>
+</ul>
+<iframe 
+    src="http://www.apache.org/ads/button.html"
+    style="border-width:0; float: left" frameborder="0" 
+    scrolling="no"
+    width="135" 
+    height="135">
+</iframe>
+    </div>
+    
+    <div class="main">
+      <div class="breadcrump" style="font-size: 80%;">
+		(TODO: breadcrumb here)
+      </div>
+      <h1 class="title">ScriptEngineIntegration</h1>
+      <div>
+	    <p><a name="ScriptEngineIntegration-IntegratingScriptingLanguages"></a></p>
+<h1 id="integrating-scripting-languages">Integrating Scripting Languages</h1>
+<p>This page should be extended with more concrete and detailed information.
+For now, we have the following information:</p>
+<ul>
+<li>There will be a talk at ApacheCon US 08 in New Orleans about creating
+JSR-223 ScriptEngineFactory and ScriptEngine implementaitons as well as how
+to integrate such implementations with Sling.</li>
+<li>From a mail on the mailing list, this is a very condensed how-to:
+         <strong> Create the ScriptEngine[Factory](factory.html)
+ implementations
+     </strong> Create a bundle comprising the above implementations as well as
+the script language implementation.
+     <em><em> Create the
+</em>META-INF/services/javax.script.ScriptEngineFactory</em> file listing the
+fully qualified name of your ScriptEngineFactory implementaiton</li>
+</ul>
+<p><a name="ScriptEngineIntegration-NotesonScriptEngines"></a></p>
+<h1 id="notes-on-scriptengines">Notes on ScriptEngines</h1>
+<p>{children:sort=title|excerpt=true}</p>
+      </div>
+    </div>
+    
+    <div class="trademarkFooter"> 
+		Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.
+	</div>
+  </body>
+</html>

Added: websites/staging/sling/trunk/content/security.html
==============================================================================
--- websites/staging/sling/trunk/content/security.html (added)
+++ websites/staging/sling/trunk/content/security.html Sun Apr 22 16:52:28 2012
@@ -0,0 +1,130 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE- 2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+  <head>
+    <title>Apache Sling - Security</title>
+    <link rel="stylesheet" href="http://sling.apache.org/site/media.data/site.css" type="text/css" media="all">
+    <link rel="icon" href="http://sling.apache.org/site/media.data/favicon.ico">
+    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
+  </head>
+  <body>
+    <div class="title">
+      <div class="logo">
+        <a href="http://sling.apache.org/site/index.html">
+          <img border="0" alt="Apache Sling" src="http://sling.apache.org/site/media.data/logo.png">
+        </a>
+      </div>
+      <div class="header">
+        <a href="http://www.apache.org/">
+          <img border="0" alt="Apache" src="http://sling.apache.org/site/media.data/apache.png">
+        </a>
+      </div>
+    </div>
+    
+    <div class="menu"> 
+      <h1 id="documentation">Documentation</h1>
+<ul>
+<li><a href="getting-started.html">Getting Started</a></li>
+<li><a href="the-sling-engine.html">The Sling Engine</a></li>
+<li><a href="development.html">Development</a></li>
+<li><a href="bundles.html">Bundles</a></li>
+<li><a href="tutorials-&amp;-how-tos.html">Tutorials &amp; How-Tos</a></li>
+<li><a href="configuration.html">Configuration</a></li>
+<li><a href="http://sling.apache.org/apidocs/sling5/index.html">API docs</a></li>
+<li><a href="http://s.apache.org/sling.wiki">Wiki</a></li>
+<li><a href="http://s.apache.org/sling.faq">FAQ</a></li>
+</ul>
+<h1 id="project-info">Project info</h1>
+<ul>
+<li><a href="http://sling.apache.org/site/downloads.cgi">Downloads</a></li>
+<li><a href="http://www.apache.org/licenses/">License</a></li>
+<li><a href="contributing.html">Contributing</a></li>
+<li><a href="news.html">News</a></li>
+<li><a href="links.html">Links</a></li>
+<li><a href="project-information.html">Project Information</a></li>
+<li><a href="https://issues.apache.org/jira/browse/SLING">Issue Tracker</a></li>
+<li><a href="http://svn.apache.org/viewvc/sling/trunk">Browse Source Repository</a></li>
+<li><a href="http://www.apache.org/security/">Security</a></li>
+</ul>
+<h1 id="sponsorship">Sponsorship</h1>
+<ul>
+<li><a href="http://www.apache.org/foundation/thanks.html">Thanks</a></li>
+<li><a href="http://www.apache.org/foundation/sponsorship.html">Become a Sponsor</a></li>
+<li><a href="http://www.apache.org/foundation/buy_stuff.html">Buy Stuff</a></li>
+</ul>
+<iframe 
+    src="http://www.apache.org/ads/button.html"
+    style="border-width:0; float: left" frameborder="0" 
+    scrolling="no"
+    width="135" 
+    height="135">
+</iframe>
+    </div>
+    
+    <div class="main">
+      <div class="breadcrump" style="font-size: 80%;">
+		(TODO: breadcrumb here)
+      </div>
+      <h1 class="title">Security</h1>
+      <div>
+	    <p><a name="Security-ReportingNewSecurityProblemswithApacheSling"></a></p>
+<h1 id="reporting-new-security-problems-with-apache-sling">Reporting New Security Problems with Apache Sling</h1>
+<p>The Apache Software Foundation takes a very active stance in eliminating
+security problems and denial of service attacks against Apache Sling.</p>
+<p>We strongly encourage folks to report such problems to our private security
+mailing list first, before disclosing them in a public forum.</p>
+<p><em>Please note that the security mailing list should only be used for
+reporting undisclosed security vulnerabilities in Apache Sling and managing
+the process of fixing such vulnerabilities. We cannot accept regular bug
+reports or other queries at this address. All mail sent to this address
+that does not relate to an undisclosed security problem in the Apache Sling
+source code will be ignored.</em></p>
+<p>If you need to report a bug that isn't an undisclosed security
+vulnerability, please use the bug reporting page.</p>
+<p>Questions about:</p>
+<ul>
+<li>how to configure Sling securely</li>
+<li>if a vulnerability applies to your particular application</li>
+<li>obtaining further information on a published vulnerability</li>
+<li>availability of patches and/or new releases</li>
+</ul>
+<p>should be addressed to the users mailing list. Please see the <a href="project-information.html">Project Information</a>
+ page for details of how to subscribe.</p>
+<p>The private security mailing address is: <a href="mailto:security@sling.apache.org.html">mailto:security@sling.apache.org</a></p>
+<p>Note that all networked servers are subject to denial of service attacks,
+and we cannot promise magic workarounds to generic problems (such as a
+client streaming lots of data to your server, or re-requesting the same URL
+repeatedly). In general our philosophy is to avoid any attacks which can
+cause the server to consume resources in a non-linear relationship to the
+size of inputs.</p>
+<p>For more information on handling security issues at the Apache Software
+Foundation please refer to the <a href="http://www.apache.org/security/">ASF Security Team</a>
+ page.</p>
+<p><a name="Security-Errorsandomissions"></a></p>
+<h1 id="errors-and-omissions">Errors and omissions</h1>
+<p>Please report any errors or omissions to <a href="mailto:security@sling.apache.org.html">mailto:security@sling.apache.org</a>
+.</p>
+      </div>
+    </div>
+    
+    <div class="trademarkFooter"> 
+		Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.
+	</div>
+  </body>
+</html>

Added: websites/staging/sling/trunk/content/servlet-resolution.html
==============================================================================
--- websites/staging/sling/trunk/content/servlet-resolution.html (added)
+++ websites/staging/sling/trunk/content/servlet-resolution.html Sun Apr 22 16:52:28 2012
@@ -0,0 +1,363 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE- 2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+  <head>
+    <title>Apache Sling - Servlet Resolution</title>
+    <link rel="stylesheet" href="http://sling.apache.org/site/media.data/site.css" type="text/css" media="all">
+    <link rel="icon" href="http://sling.apache.org/site/media.data/favicon.ico">
+    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
+  </head>
+  <body>
+    <div class="title">
+      <div class="logo">
+        <a href="http://sling.apache.org/site/index.html">
+          <img border="0" alt="Apache Sling" src="http://sling.apache.org/site/media.data/logo.png">
+        </a>
+      </div>
+      <div class="header">
+        <a href="http://www.apache.org/">
+          <img border="0" alt="Apache" src="http://sling.apache.org/site/media.data/apache.png">
+        </a>
+      </div>
+    </div>
+    
+    <div class="menu"> 
+      <h1 id="documentation">Documentation</h1>
+<ul>
+<li><a href="getting-started.html">Getting Started</a></li>
+<li><a href="the-sling-engine.html">The Sling Engine</a></li>
+<li><a href="development.html">Development</a></li>
+<li><a href="bundles.html">Bundles</a></li>
+<li><a href="tutorials-&amp;-how-tos.html">Tutorials &amp; How-Tos</a></li>
+<li><a href="configuration.html">Configuration</a></li>
+<li><a href="http://sling.apache.org/apidocs/sling5/index.html">API docs</a></li>
+<li><a href="http://s.apache.org/sling.wiki">Wiki</a></li>
+<li><a href="http://s.apache.org/sling.faq">FAQ</a></li>
+</ul>
+<h1 id="project-info">Project info</h1>
+<ul>
+<li><a href="http://sling.apache.org/site/downloads.cgi">Downloads</a></li>
+<li><a href="http://www.apache.org/licenses/">License</a></li>
+<li><a href="contributing.html">Contributing</a></li>
+<li><a href="news.html">News</a></li>
+<li><a href="links.html">Links</a></li>
+<li><a href="project-information.html">Project Information</a></li>
+<li><a href="https://issues.apache.org/jira/browse/SLING">Issue Tracker</a></li>
+<li><a href="http://svn.apache.org/viewvc/sling/trunk">Browse Source Repository</a></li>
+<li><a href="http://www.apache.org/security/">Security</a></li>
+</ul>
+<h1 id="sponsorship">Sponsorship</h1>
+<ul>
+<li><a href="http://www.apache.org/foundation/thanks.html">Thanks</a></li>
+<li><a href="http://www.apache.org/foundation/sponsorship.html">Become a Sponsor</a></li>
+<li><a href="http://www.apache.org/foundation/buy_stuff.html">Buy Stuff</a></li>
+</ul>
+<iframe 
+    src="http://www.apache.org/ads/button.html"
+    style="border-width:0; float: left" frameborder="0" 
+    scrolling="no"
+    width="135" 
+    height="135">
+</iframe>
+    </div>
+    
+    <div class="main">
+      <div class="breadcrump" style="font-size: 80%;">
+		(TODO: breadcrumb here)
+      </div>
+      <h1 class="title">Servlet Resolution</h1>
+      <div>
+	    <p><a name="ServletResolution-ServletResolution"></a></p>
+<h1 id="servlet-resolution">Servlet Resolution</h1>
+<p>{warning:title=Out Of Sync}
+Please note that the description on this page is out of sync with the most
+recent developments going on as part of implementing issue <a href="https://issues.apache.org/jira/browse/SLING-387">SLING-387</a>
+. See the links to integration tests at the end of this page for the
+Current Truth.</p>
+<p>Please see the new <a href="servlets.html">Servlets</a>
+ page.
+{warning}</p>
+<p>{toc:minLevel=2}</p>
+<p><a name="ServletResolution-ServletsareResources"></a></p>
+<h2 id="servlets-are-resources">Servlets are Resources</h2>
+<p>As explained on the <a href="resources.html">Resources</a>
+ page, the Resource is the central data abstraction of Sling. In this
+contexts, Servlets are of course also povided as Resources. As such
+Servlets may be enumerated by iterating the Resource tree and Servlets may
+be retrieved through the <em>ResourceResolver</em>.</p>
+<p>To show a Servlet inside the Resource tree, the <em>sling/servlet-resolver</em>
+project provides a <em>ServletResourceProvider</em> implementing the
+<em>ResourceProvider</em> interface. For each Servlet registered as an OSGi
+service with one or more defined service reference properties a
+<em>ServletResourceProvider</em> instance is registered.</p>
+<p>The following service reference properties are defined for Servlets defined
+as OSGi services of type <em>javax.servlet.Servlet</em>:</p>
+<table>
+<tr><th> Name </th><th> Description </th></tr>
+<tr><td> *sling.servlet.paths* </td><td> A list of absolute paths under which the
+servlet is accessible as a Resource. The property value must either be a
+single String, an array of Strings or a Vector of Strings. </td></tr>
+<tr><td> *sling.servlet.resourceTypes* </td><td> The resource type(s) supported by the
+servlet. The property value must either be a single String, an array of
+Strings or a Vector of Strings. This property is ignored if the
+*sling.servlet.paths* property is set. </td></tr>
+<tr><td> *sling.servlet.selectors* </td><td>  The request URL selectors supported by the
+servlet. The selectors must be configured as they would be specified in the
+URL that is as a list of dot-separated strings such as <em>print.a4</em>.
+The property value must either be a single String, an array of Strings or a
+Vector of Strings. This property is ignored if the *sling.servlet.paths*
+property is set. </td></tr>
+<tr><td> *sling.servlet.extensions* </td><td> The request URL extensions supported by
+the servlet for GET requests. The property value must either be a single
+String, an array of Strings or a Vector of Strings. This property is
+ignored if the *sling.servlet.paths* property is set. </td></tr>
+<tr><td> *sling.servlet.methods* </td><td>  The request methods supported by the
+servlet. The property value must either be a single String, an array of
+Strings or a Vector of Strings. This property is ignored if the
+*sling.servlet.paths* property is set. </td></tr>
+<tr><td> *sling.servlet.prefix* </td><td>  The absolute prefix to make relative paths
+absolute. This property is a String and is optional. If it is not set, the
+actual prefix used is derived from the search path of the
+*ResourceResolver* at the time of registration. </td></tr>
+</table>
+
+<p>For a Servlet registered as an OSGi service to be used by the Sling Servlet
+Resolver, the following restrictions apply:</p>
+<ol>
+<li>Either the <em>sling.servlet.paths</em> or the
+<em>sling.servlet.resourceTypes</em> service reference property must be set. If
+neither is set, the Servlet service is ignored.</li>
+<li>If the <em>sling.servlet.paths</em> property is set, all other
+<em>sling.servlet.</em>* properties are ignored.</li>
+<li>Otherwise a Resource provider is registered for the Servlet for each
+permutation resource types, selectors, extensions and methods.</li>
+</ol>
+<p>Each path to be used for registration -- either from the
+<em>sling.servlet.paths</em> property or constructed from the other
+<em>sling.servlet.</em><em> properties -- must be absolute. Any relative path is
+made absolute by prefixing it with a root path. This prefix may be set with
+the </em>sling.servlet.prefix<em> service registration property. If this
+property is not set, the first entry in the </em>ResourceResolver<em> search
+path for the </em>ResourceResolver.getResource(String)<em> method is used as the
+prefix. If this entry cannot be derived, a simpe slash -- </em>/* -- is used
+as the prefix.</p>
+<p><a name="ServletResolution-Example:RegistrationbyPath"></a></p>
+<h3 id="example-registration-by-path">Example: Registration by Path</h3>
+<div class="codehilite"><pre><span class="n">sling</span><span class="o">.</span><span class="n">servlet</span><span class="o">.</span><span class="n">paths</span> <span class="o">=</span> <span class="p">[</span> <span class="s">&quot;/libs/sling/sample/html&quot;</span><span class="p">,</span> <span class="s">&quot;/libs/sling/sample/txt&quot;</span> <span class="p">]</span>
+<span class="n">sling</span><span class="o">.</span><span class="n">servlet</span><span class="o">.</span><span class="n">resourceTypes</span> <span class="o">=</span> <span class="p">[</span> <span class="s">&quot;sling/unused&quot;</span> <span class="p">]</span>
+<span class="n">sling</span><span class="o">.</span><span class="n">servlet</span><span class="o">.</span><span class="n">selectors</span> <span class="o">=</span> <span class="p">[</span> <span class="s">&quot;img&quot;</span> <span class="p">]</span>
+<span class="n">sling</span><span class="o">.</span><span class="n">servlet</span><span class="o">.</span><span class="n">extensions</span> <span class="o">=</span> <span class="p">[</span> <span class="s">&quot;html&quot;</span><span class="p">,</span> <span class="s">&quot;txt&quot;</span><span class="p">,</span> <span class="s">&quot;json&quot;</span> <span class="p">]</span>
+</pre></div>
+
+
+<p>A Servlet service registered with these properties is registered under the
+following paths:</p>
+<ul>
+<li><em>/libs/sling/sample/html</em></li>
+<li><em>/libs/sling/sample/txt</em></li>
+</ul>
+<p>The registration properties <em>sling.servlet.resourceTypes</em>,
+<em>sling.servlet.selectors</em> and <em>sling.servlet.extensions</em> are ignored
+because the <em>sling.servlet.paths</em> property is set.</p>
+<p><a name="ServletResolution-Example:RegistrationbyResourceTypeetc."></a></p>
+<h3 id="example-registration-by-resource-type-etc">Example: Registration by Resource Type etc.</h3>
+<div class="codehilite"><pre><span class="n">sling</span><span class="o">.</span><span class="n">servlet</span><span class="o">.</span><span class="n">resourceTypes</span> <span class="o">=</span> <span class="p">[</span> <span class="s">&quot;sling/unused&quot;</span> <span class="p">]</span>
+<span class="n">sling</span><span class="o">.</span><span class="n">servlet</span><span class="o">.</span><span class="n">selectors</span> <span class="o">=</span> <span class="p">[</span> <span class="s">&quot;img&quot;</span><span class="p">,</span> <span class="s">&quot;tab&quot;</span> <span class="p">]</span>
+<span class="n">sling</span><span class="o">.</span><span class="n">servlet</span><span class="o">.</span><span class="n">extensions</span> <span class="o">=</span> <span class="p">[</span> <span class="s">&quot;html&quot;</span><span class="p">,</span> <span class="s">&quot;txt&quot;</span><span class="p">,</span> <span class="s">&quot;json&quot;</span> <span class="p">]</span>
+</pre></div>
+
+
+<p>A Servlet service registered with these properties is registered under the
+following paths:</p>
+<ul>
+<li><em><em>prefix</em>/sling/unused/img/html</em></li>
+<li><em><em>prefix</em>/sling/unused/img/txt</em></li>
+<li><em><em>prefix</em>/sling/unused/img/json</em></li>
+<li><em><em>prefix</em>/sling/unused/tab/html</em></li>
+<li><em><em>prefix</em>/sling/unused/tab/txt</em></li>
+<li><em><em>prefix</em>/sling/unused/tab/json</em></li>
+</ul>
+<p>As explained the script is registered for each permutation of the resource
+types, selectors and extension. See above For an explanation of how
+<em><em>prefix</em></em> is defined.</p>
+<p><a name="ServletResolution-ScriptsareServlets"></a></p>
+<h2 id="scripts-are-servlets">Scripts are Servlets</h2>
+<p>The Sling API defines a <em>SlingScript</em> interface which is used to
+represent (executable) scripts inside of Sling. This interface is
+implemented in the <em>scripting/resolver</em> bundle in the
+<em>DefaultSlingScript</em> class which also implements the
+<em>javax.servlet.Servlet</em>.</p>
+<p>To further simplify the access to scripts from the Resource tree, the
+<em>scripting/resolver</em> bundle registers an <em>AdapterFactory</em> to adapt
+Resources to Scripts and Servlets. In fact the adapter factory returns
+instances of the <em>DefaultSlingScript</em> class for both Scripts and
+Servlets.</p>
+<p>This functionality is used by the <em>ServletResolver.resolveServlet</em>
+implementation in the <em>sling/servlet-resolver</em> bundle: This
+implementation just looks up any Resource in the resource tree according
+its lookup algorithm (see below). The first matching Resource adapting to a
+<em>javax.servlet.Servlet</em> is used for processing the resource.</p>
+<p>So from the perspective of the Servlet resolver, scripts and servlets are
+handled exactly the same.</p>
+<p><a name="ServletResolution-ResolutionProcess"></a></p>
+<h2 id="resolution-process">Resolution Process</h2>
+<p>The Servlet Resolution Process four elements of a
+<em>SlingHttpServletRequest</em>:</p>
+<ol>
+<li>The <em>resource type</em> as retrieved through
+<em>request.getResource().getResourceType()</em>. Because the resource type may
+be a node type such as <em>nt:file</em>, the resource type is mangled into a path
+by replacing any colons contained to forward slashs. Also, any backslashes
+contained are replaced to forward slashes. This should give a relative
+path. Of course a resource type may also be set to an absolute path. See
+below.</li>
+<li>The <em>request selectors</em> as retrieved through
+<em>request.getRequestPathInfo().getSelectorString()</em>. The selector string
+is turned into a realtive path by replacing all separating dots by forward
+slashes. For example the selector string <em>print.a4</em> is  converted into
+the relative path <em>print/a4</em>.</li>
+<li>The <em>request extension</em> as retrieved through
+<em>request.getRequestPathInfo().getExtension()</em> if the request method is
+<em>GET</em> or <em>HEAD</em> and the request extension is not empty.</li>
+<li>The <em>request method name</em> for any request method except <em>GET</em> or
+<em>HEAD</em> or if the request extension is empty.</li>
+</ol>
+<p>The <em>resource type</em> is used as a (relative) parent path to the Servlet
+while the <em>request extension</em> or <em>request method</em> is used as the Servlet
+(base) name. The Servlet is retrieved from the Resource tree by calling the
+<em>ResourceResolver.getResource(String)</em> method which handles absolute and
+relative paths correctly by searching realtive paths in the configured
+search path.</p>
+<p>The pseudo-code for Servlet resolution is as follows:</p>
+<div class="codehilite"><pre><span class="n">Servlet</span> <span class="n">resolveServlet</span><span class="p">(</span><span class="n">SlingHttpServletRequest</span> <span class="n">request</span><span class="p">)</span> <span class="p">{</span>
+
+    <span class="n">String</span> <span class="n">resourceType</span> <span class="o">=</span> <span class="n">request</span><span class="o">.</span><span class="n">getResource</span><span class="p">()</span><span class="o">.</span><span class="n">getResourceType</span><span class="p">();</span>
+    <span class="n">resourceType</span> <span class="o">=</span> <span class="n">resourceType</span><span class="o">.</span><span class="n">replaceAll</span><span class="p">(</span><span class="s">&quot;\\:&quot;</span><span class="p">,</span> <span class="s">&quot;/&quot;</span><span class="p">);</span>
+
+    <span class="n">String</span> <span class="n">baseName</span><span class="p">;</span>
+    <span class="k">if</span> <span class="p">((</span><span class="s">&quot;GET&quot;</span><span class="o">.</span><span class="n">equals</span><span class="p">(</span><span class="n">request</span><span class="o">.</span><span class="n">getMethod</span><span class="p">())</span> <span class="o">||</span>
+</pre></div>
+
+
+<p>"HEAD".equals(request.getMethod())
+            &amp;&amp; request.getRequestPathInfo().getExtension() != null) {
+        baseName = request.getRequestPathInfo().getExtension();
+        } else {
+        baseName = request.getMethod();
+        }</p>
+<div class="codehilite"><pre>    <span class="k">if</span> <span class="p">(</span><span class="n">request</span><span class="o">.</span><span class="n">getRequestPath</span><span class="p">()</span><span class="o">.</span><span class="n">getSelectorString</span><span class="p">()</span> <span class="o">!=</span> <span class="n">null</span><span class="p">)</span> <span class="p">{</span>
+    <span class="n">String</span> <span class="n">selectors</span> <span class="o">=</span> <span class="n">request</span><span class="o">.</span><span class="n">getRequestPath</span><span class="p">()</span><span class="o">.</span><span class="n">getSelectorString</span><span class="p">();</span>
+    <span class="n">selectors</span> <span class="o">=</span> <span class="n">selectors</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s">&#39;.&#39;</span><span class="p">,</span> <span class="s">&#39;/&#39;</span><span class="p">);</span>
+    <span class="k">while</span> <span class="p">(</span><span class="n">selectors</span> <span class="o">!=</span> <span class="n">null</span><span class="p">)</span> <span class="p">{</span>
+        <span class="n">String</span> <span class="n">path</span> <span class="o">=</span> <span class="n">resourceType</span> <span class="o">+</span> <span class="s">&quot;/&quot;</span> <span class="o">+</span> <span class="n">selectors</span> <span class="o">+</span> <span class="s">&quot;/&quot;</span> <span class="o">+</span> <span class="n">baseName</span><span class="p">;</span>
+        <span class="n">Servlet</span> <span class="n">servlet</span> <span class="o">=</span> <span class="n">findServletFor</span><span class="p">(</span><span class="n">path</span><span class="p">);</span>
+        <span class="k">if</span> <span class="p">(</span><span class="n">servlet</span> <span class="o">!=</span> <span class="n">null</span><span class="p">)</span> <span class="p">{</span>
+        <span class="k">return</span> <span class="n">servlet</span><span class="p">;</span>
+        <span class="p">}</span>
+
+        <span class="nb">int</span> <span class="n">lastSlash</span> <span class="o">=</span> <span class="n">selectors</span><span class="o">.</span><span class="n">lastIndexOf</span><span class="p">(</span><span class="s">&#39;/&#39;</span><span class="p">);</span>
+        <span class="k">if</span> <span class="p">(</span><span class="n">lastSlash</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
+        <span class="n">selectors</span> <span class="o">=</span> <span class="n">selectors</span><span class="o">.</span><span class="n">substring</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">lastSlash</span><span class="p">);</span>
+        <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
+        <span class="n">selectors</span> <span class="o">=</span> <span class="n">null</span><span class="p">;</span>
+        <span class="p">}</span>
+    <span class="p">}</span>
+    <span class="p">}</span>
+
+    <span class="n">String</span> <span class="n">path</span> <span class="o">=</span> <span class="n">resourceType</span> <span class="o">+</span> <span class="s">&quot;/&quot;</span> <span class="o">+</span> <span class="n">baseName</span><span class="p">;</span>
+    <span class="k">return</span> <span class="n">findScriptFor</span><span class="p">(</span><span class="n">path</span><span class="p">);</span>
+<span class="p">}</span>
+
+<span class="n">Servlet</span> <span class="n">findScriptFor</span><span class="p">(</span><span class="n">path</span><span class="p">)</span> <span class="p">{</span>
+    <span class="sr">//</span> <span class="n">Find</span> <span class="n">a</span> <span class="n">Servlet</span> <span class="ow">or</span> <span class="n">Script</span> <span class="n">with</span> <span class="n">the</span> <span class="n">given</span> <span class="n">path</span> <span class="n">in</span> <span class="n">the</span> <span class="n">search</span> <span class="n">path</span>
+    <span class="sr">//</span> <span class="n">where</span> <span class="n">the</span> <span class="n">Script</span> <span class="n">is</span> <span class="n">allowed</span> <span class="n">to</span> <span class="n">have</span> <span class="n">Script</span> <span class="n">language</span> <span class="n">specific</span>
+    <span class="sr">//</span> <span class="n">extension</span><span class="p">,</span> <span class="n">such</span> <span class="n">as</span> <span class="o">.</span><span class="n">js</span><span class="p">,</span> <span class="o">.</span><span class="n">jsp</span><span class="p">,</span> <span class="n">etc</span><span class="o">.</span>
+<span class="p">}</span>
+</pre></div>
+
+
+<p><a name="ServletResolution-DefaultServlet(s)"></a></p>
+<h2 id="default-servlets">Default Servlet(s)</h2>
+<p>As explained in the Resolution Process section above, a default Servlet is
+selected if no servlet for the current resource type can be found. To make
+the provisioning of a default Servlet as versatile as provisioning per
+resource type Servlets (or scripts), the default Servlet is selected with
+just a special resource type <em>sling/servlet/default</em>.</p>
+<p>The actual Servlet or Script called as the default Servlet is resolved
+exactly the same way as for any resource type. That is, also for the
+default Servlet selection, the request selectors and extension or method
+are considered. Also, the Servlet may be a Servlet registered as an OSGi
+service and provided through a Servlet Resource provider or it may be a
+Script stored in the repository or provided by the bundle.</p>
+<p>Finally, if not even a registered default Servlet may be resolved for the
+request, because none has been registered, the <em>sling/servlet-resolve</em>
+bundle provides a fall back <em>DefaultServlet</em> with the following
+functionality:</p>
+<ul>
+<li>If the request has no extension and the Resource of the request adapts
+to an <em>InputStream</em>, the contents of the resoure is stream out as the
+response. The response content type is taken from the <em>sling.contentType</em>
+Resource meta data or derived from the Resource path. If the
+<em>sling.characterEncoding</em> Resource meta data property is set, that value
+is used as the response character encoding. Currently there is no ETag and
+modification time stamp support.</li>
+<li>Otherwise if the object has an OCM mapping, the properties of the
+mapped object are printed.</li>
+<li>Otherwise just the path of the Resource is printed.</li>
+</ul>
+<p><a name="ServletResolution-ErrorHandlerServlet(s)"></a></p>
+<h2 id="error-handler-servlets">Error Handler Servlet(s)</h2>
+<p>The <em>sling/servlet-resolver</em> project also provides an implementation of
+the Sling Core <em>ErrorHandler</em> interface, which applies the same Servlet
+resolution process as used for normal request processing. Error handler
+Servlets and Scripts are looked up with the predefined resource
+<em>sling/servlet/errorhandler</em> and an error specific name:</p>
+<ul>
+<li><em>HTTP Status Code Handling</em>: To handle HTTP status code as used by the
+<em>HttpServletResponse.sendError</em> methods, status code is used as the
+Servlet name. For example to provide a handler for status code 404
+(NOT_FOUND), you could create a script
+<em>prefix/sling/servlet/errorhandler/404.esp</em> or for a status code 500
+(INTERNAL_SERVER_ERRROR), you might want to register a Servlet at
+<em>prefix/sling/servlet/errorhandler/500</em>.</li>
+<li><em>Throwable Handling</em>: To handle uncaught <em>Throwables</em> the simple
+name of the <em>Throwable</em> class is used as the Servlet name. Similarly to
+the Java <em>try-catch</em> clauses the class hierarchy is supported. That is to
+handle an uncaught <em>FileNotFoundException</em>, the names
+<em>FileNotFoundException</em>, <em>IOException</em>, <em>Exception</em>, <em>Throwable</em>
+are checked for a Servlet and the first one found is then used. Again, the
+Serlvet may be a Servlet registered as an OSGi service or may be a plain
+script stored in the JCR repository or provided through some custom
+Resource provider.</li>
+</ul>
+<p><a name="ServletResolution-Integrationtests"></a></p>
+<h2 id="integration-tests">Integration tests</h2>
+<p>A set of simple example servlets is available in the <a href="http://svn.apache.org/repos/asf/incubator/sling/trunk/launchpad/test-services">launchpad/test-services module</a>
+. </p>
+<p>Integration tests in the <a href="http://svn.apache.org/repos/asf/incubator/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/resolution">launchpad/testing module</a>
+ verify that these examples are correct.</p>
+<p>Contributions to these tests and examples are welcome, of course!</p>
+      </div>
+    </div>
+    
+    <div class="trademarkFooter"> 
+		Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.
+	</div>
+  </body>
+</html>



Mime
View raw message