This is an automated email from the ASF dual-hosted git repository. kwin pushed a commit to branch bugfix/clarify-resource-type-normalization in repository https://gitbox.apache.org/repos/asf/sling-site.git
commit fdd72ac0b232b879e132dc883b604d244835517e Author: Konrad Windszus <[email protected]> AuthorDate: Wed Oct 1 09:39:44 2025 +0200 Resource type normalization only happens during servlet resolving The regular resource type is never normalized. Compare with the discussion https://lists.apache.org/thread/mscb5tql7tdrwv6bd77vv73vcgodoo2j. --- .../jbake/content/documentation/the-sling-engine/resources.md | 2 +- .../jbake/content/documentation/the-sling-engine/servlets.md | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/jbake/content/documentation/the-sling-engine/resources.md b/src/main/jbake/content/documentation/the-sling-engine/resources.md index 5335c03b3..0342ac28d 100644 --- a/src/main/jbake/content/documentation/the-sling-engine/resources.md +++ b/src/main/jbake/content/documentation/the-sling-engine/resources.md @@ -36,7 +36,7 @@ implementations provided by Sling, the assignments are as follows: | Provider | Resource Type | Resource Super Type | |---|---|---| -| JCR | The value of the `sling:resourceType` property or the primary node type if the property is not set (a namespace separator colon is replaced by a slash, e.g. the `nt:file` primary node type is mapped to the `nt/file` resource type | The value of the `sling:resourceSuperType` of the Resource node or resource super type of the resource pointed to by the resource type (when accessed with `ResourceResolver.getResource(String)` | +| JCR | The value of the `sling:resourceType` property or the primary node type (from `jcr:primaryType`) if the property is not set | The value of the `sling:resourceSuperType` of the Resource node or resource super type of the resource pointed to by the resource type (when accessed with `ResourceResolver.getResource(String)` | | File System | File based resources are of type `nt/file`; folder based resources are of type `nt/folder` corresponding to the respective JCR primary node type | none | | Bundle | File based resources are of type `nt/file`; folder based resources are of type `nt/folder` corresponding to the respective JCR primary node type | none | | Servlet | The absolute path of the resource appended with the suffix `.servlet` | `sling/bundle/resource` | diff --git a/src/main/jbake/content/documentation/the-sling-engine/servlets.md b/src/main/jbake/content/documentation/the-sling-engine/servlets.md index e407389e6..116a7d79c 100644 --- a/src/main/jbake/content/documentation/the-sling-engine/servlets.md +++ b/src/main/jbake/content/documentation/the-sling-engine/servlets.md @@ -9,8 +9,13 @@ tags=servlets,core ## Servlet Resolving First of all Sling looks up the resource identified by the URL - typically a path inside the JCR repository, which is annotated by the `sling:resourceType` property -which defines the resource type of that resource. Using this resource type (which is usually a relative resource path, -eg. "myblog/comment"), servlets (or scripts) are looked up. For more details about how the initial resource is identified for a specific request URL look at [URL decomposition](/documentation/the-sling-engine/url-decomposition.html). +which defines the resource type of that resource. +The resource type is first normalized (which replaces `:` by `\` as `:` cannot be used in resource names, but for example is frequently used by resources provided by JCR provider which leverages `jcr:primaryType` which usually contains namespaced values like `nt:file`). + +Afterwards this normalized resource type (which is usually a relative resource path, +eg. "myblog/comment") is used to lookup servlets (or scripts). For more details about how the initial resource is identified for a specific request URL look at [URL decomposition](/documentation/the-sling-engine/url-decomposition.html). + +Alternatively a servlet can be addressed by requests directly through the path it is registered on (without leveraging the `sling:resourceType` indirection). This option is not available for scripts, though. Servlets and scripts are themselves resources in Sling and thus have a resource path: this is either the location in the resource repository, the resource type in a servlet component configuration or the "virtual" bundle resource path
