Skip to content
CMO & CTO
CMO & CTO

Closing the Bridge Between Marketing and Technology, By Luis Fernandez

  • Digital Experience
    • Experience Strategy
    • Experience-Driven Commerce
    • Multi-Channel Experience
    • Personalization & Targeting
    • SEO & Performance
    • User Journey & Behavior
  • Marketing Technologies
    • Analytics & Measurement
    • Content Management Systems
    • Customer Data Platforms
    • Digital Asset Management
    • Marketing Automation
    • MarTech Stack & Strategy
    • Technology Buying & ROI
  • Software Engineering
    • Software Engineering
    • Software Architecture
    • General Software
    • Development Practices
    • Productivity & Workflow
    • Code
    • Engineering Management
    • Business of Software
    • Code
    • Digital Transformation
    • Systems Thinking
    • Technical Implementation
  • About
CMO & CTO

Closing the Bridge Between Marketing and Technology, By Luis Fernandez

Sling Resource Resolution: URLs as a Feature

Posted on October 21, 2011 By Luis Fernandez

What if your URLs were not an afterthought in your app but the main character from the very first line of code. What if links shaped your content model instead of getting patched at the end with regex and a bag of filters. If your brain nodded there is a good chance you will like how Apache Sling treats resource resolution. Do we really need more controller glue or do we just need to map a clean URL to a content resource and let the right script render it. That is the idea that keeps pulling me back to Sling and why URLs in Sling feel like a feature not a footnote.

In Sling the URL is the starting point.

Sling turns a request path into a Resource that lives in a JCR. From there type hints on the resource pick the script. No servlet mapping xml. No giant front controller. The parts of the URL matter. Path points to the resource. Selectors are extra hints like widget or print. The extension suggests the format like html json txt. And the suffix carries an extra resource path if you want to reference something else. This is clean for SEO and clean for code. You keep your content under /content or whatever tree makes sense and you let the URL describe the view. The mental model is simple. Resolve resource then resolve script then render.

Plain words for a simple flow.

Scripts live alongside the component that knows how to render. The resource has a sling:resourceType, say site/components/product. Sling will try to find a script for that type that matches the request. If you hit /content/site/en/products/widget.print.html Sling looks for a script that supports the type and the selectors and the extension. In this world JSP and ESP are common picks. HTL is not in the mix yet. The best part is how this keeps your URLs flat while your content stays structured. URLs stop leaking storage details and still carry useful intent for caching and for users.

// inside a Sling servlet or script
Resource res = request.getResource();
ValueMap vm = res.adaptTo(ValueMap.class);

SlingHttpServletRequest req = request;
RequestPathInfo info = req.getRequestPathInfo();

String path = res.getPath();              // /content/site/en/products
String selectors = info.getSelectorString(); // widget.print
String ext = info.getExtension();           // html
String suffix = info.getSuffix();           // maybe /sku/123

Selectors are like light switches you add to a URL. Flip on widget to add chrome. Add print for a bare template. Put json for a raw view. You avoid query strings for things that are part of the template choice. CDNs and proxies like that since the cache key is clear. Search engines like it because the link tells a story. The extension is not a file type from your disk. It is just a hint for the response. That keeps your content portable inside the JCR without leaking storage details.

Readable and still precise.

The other trick I love is Sling Mappings. You can keep all content under /content and still serve it from the root without a servlet filter that rewrites everything. Create mapping nodes under /etc/map and let Sling do the rewrite both ways. That means author links stay short in the browser and still resolve back to the right resource inside the repo. You can also set up 301s for old sections if you are migrating a site. Move a tree in the JCR and keep the link juice with a tiny mapping. This cuts down on brittle code and keeps SEO friendly URLs intact while your structure evolves behind the scenes.

# JCR nodes for /etc/map
/etc/map
  http
    localhost.4502
      sling:match = localhost.4502/(.*)
      sling:internalRedirect = /$1
    short-root
      sling:match = localhost.4502/(en|de)/(.*)
      sling:internalRedirect = /content/site/$1/$2
    legacy-products
      sling:match = localhost.4502/store/(.*)
      sling:redirect = https://localhost:4502/en/products/$1  // 301

You can inspect the resolver in the Felix console and watch how a path goes from link to resource to script. I run quick checks with curl and look at response headers and the selected script in logs. This is also what powers Adobe CQ5 which sits on Sling and Felix. With Adobe picking up PhoneGap this week the web stack story keeps getting more interesting. Sling fits nicely when you want content first sites where every URL is a contract. Build content types in the repo. Attach scripts that match selectors and extensions. Let the resolver tie it all together. Less glue. Fewer surprises.

# quick sanity checks
curl -I http://localhost:4502/en/products.widget.html
curl -I http://localhost:4502/en/products.print.json
curl -L http://localhost:4502/store/old-sku

Treat the URL as a contract and Sling will do the heavy lifting.

Software Engineering Technical Implementation

Post navigation

Previous post
Next post
  • Digital Experience (94)
    • Experience Strategy (19)
    • Experience-Driven Commerce (5)
    • Multi-Channel Experience (9)
    • Personalization & Targeting (21)
    • SEO & Performance (10)
  • Marketing Technologies (92)
    • Analytics & Measurement (14)
    • Content Management Systems (45)
    • Customer Data Platforms (4)
    • Digital Asset Management (8)
    • Marketing Automation (6)
    • MarTech Stack & Strategy (10)
    • Technology Buying & ROI (3)
  • Software Engineering (310)
    • Business of Software (20)
    • Code (30)
    • Development Practices (52)
    • Digital Transformation (21)
    • Engineering Management (25)
    • General Software (82)
    • Productivity & Workflow (30)
    • Software Architecture (85)
    • Technical Implementation (23)
  • 2025 (12)
  • 2024 (8)
  • 2023 (18)
  • 2022 (13)
  • 2021 (3)
  • 2020 (8)
  • 2019 (8)
  • 2018 (23)
  • 2017 (17)
  • 2016 (40)
  • 2015 (37)
  • 2014 (25)
  • 2013 (28)
  • 2012 (24)
  • 2011 (30)
  • 2010 (42)
  • 2009 (25)
  • 2008 (13)
  • 2007 (33)
  • 2006 (26)

Ab Testing Adobe Adobe Analytics Adobe Target AEM agile-methodologies Analytics architecture-patterns CDP CMS coding-practices content-marketing Content Supply Chain Conversion Optimization Core Web Vitals customer-education Customer Data Platform Customer Experience Customer Journey DAM Data Layer Data Unification documentation DXP Individualization java Martech metrics mobile-development Mobile First Multichannel Omnichannel Personalization product-strategy project-management Responsive Design Search Engine Optimization Segmentation seo spring Targeting Tracking user-experience User Journey web-development

©2025 CMO & CTO | WordPress Theme by SuperbThemes