Q8.) Describe Resource Resolution in Sling.

The below diagram explains the steps which Sling takes to resolve a URL to a script. Please go through the screenshot first and then the explanation along with examples for complete understanding .

I would like to bring up an example to help to understand it better. Let the URL be :


First, Sling will look in the repository for a file at exactly this location. If such a file is found, it will be streamed out as is. But if there is no file to be found Sling will look for a repository node located at:


(and will return 404 if no such node exists). If the node is found, Sling then looks for a special property on that node named “sling:resourceType,” which (if present) determines the resource type for that node. Sling will look under /apps (then /lib) to find a script that applies to the resource type. Let’s consider a very simple example. Suppose that the resource type for the above node is “hr/job.” In that case, Sling will look for a script called /apps/hr/job/job.jsp or /apps/hr/job/job.esp. (The .esp extension is for ECMAScript server pages.) However, if such a script doesn’t exist, Sling will then look for /apps/hr/job/GET.jsp (or .esp) to service the GET request. Sling will also count apps/hr/job/html.jsp (or .esp) as a match, if it finds it.

Where things get interesting is when selectors are used in the target path. In content-centric applications, the same content (the same JCR nodes, in Sling) must often be displayed in different variants (e.g., as a teaser view versus a detail view). This can be accomplished through extra name steps called “selectors.” For example:


In this case, .detail is a selector. Sling will look for a script at /apps/hr/job/job.detail.esp. But /apps/hr/job/job.detail.html.esp will also work.
It’s possible to use multiple selectors in a resource URL. For example, consider:


In this case, there are two selectors (.print and .a4) as well as a file extension (html). How does Sling know where to start looking for a matching script? Well, it turns out that if a file called a4.html.jsp exists under a path of /apps/hr/jobs/print/, it will be chosen before any other scripts that might match. If such a file doesn’t exist but there happens to be a file, html.jsp, under /apps/hr/jobs/print/a4/, that file would be chosen next.

Assuming all of the following scripts exist in the proper locations, they would be accessed in the order of preference shown:

  1. /apps/hr/jobs/print/a4.html.jsp
  2. /apps/hr/jobs/print/a4/html.jsp
  3. /apps/hr/jobs/print/a4.jsp
  4. /apps/hr/jobs/print.html.jsp
  5. /apps/hr/jobs/print.jsp
  6. /apps/hr/jobs/html.jsp
  7. /apps/hr/jobs/jobs.jsp
  8. /apps/hr/jobs/GET.jsp

Within the location(s) found through above mechanism a script is searched whose script name matches the pattern


where the fields have the following meaning:

  •      {resourceTypeLabel} – the last segment of the {resourceTypePath} This part is required. Only scripts whose name starts with this name are considerd
  •      {selectorString} – the selector string as per RequestPathInfo.getSelectorString . This part is optional. The more selectors of the selector string match, the better.
  •      {requestMethod} The request method name. This is optional for GET or HEAD requests and is required for non-GET/non-HEAD requests
  •      {requestExtension}  The extension of the request. This is optional.
  •      {scriptExtension}  The extension indicating the script language. Not used for selecting  the script but for selecting the ScriptEngine. This is of course not existing for servlets.
Protocol host content path selector(s) extension suffix  param(s)

Q9.) How good is CQ5 when compared to other CMS?

CQ5 is the latest CMS available in market. Adobe purchased it from Day. Cq5 provide rich graphical UI to build websites; it also provides various levels of user access rights to control create, edit and publish.
There are workflows for creating, editing and publishing of content in a handy way. Users can manage a repository of digital assets like images, documents and integrate them in wide varieties to their system.
Best search mechanism to find contents, no matter where it is stored in your system location.
Ease in settings up social collaboration items like blogs, groups.
It also provide tagging utility to organize the digital assets such as images.

Q10.) What are the design patterns used in day CQ5?

Any patterns that your customized application demands. OSGi makes CQ5 very modular, so you should be free to use whatever suits your needs.

Other Links which you may (infact MUST) refer are:


5 thoughts on “Basics

  1. Pingback: How to Prepare ? – CQ5 AEM Tricks of Trade

  2. Pingback: AEM Interview Q & A | AEM basics & tactics

  3. Pingback: Wiring Harness Design Engineer Interview Questions - free wiring diagrams

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s