Resolving script for JSON
I am trying to understand how the location of a rendering script is resolved when using a json extension. I am also interested in the same question but when also including a selector.
I have been puzzling over the statements in this article :-
http://dev.day.com/docs/en/cq/current/developing/the_basics.html#Sling%2520Request%2520Processing
It all seems to work fine when the URL uses a .html extension, but if I use .json instead, it all goes a bit pear-shaped ?
Under the title 'Locating the script' from the article, it states :-
URLs in other formats, not ending with .html For example ../content/corporate/jobs/developer.pdf The script will be /apps/hr/jobs/jobs.pdf.esp; the suffix is added to the script name. URLs with selectors Selectors can be used to display the same content in an alternative format. For example a printer friendly version, an rss feed or a summary. If we look at a printer friendly version where the selector could be print; as in ../content/corporate/jobs/developer.print.html The script will be /apps/hr/jobs/jobs.print.esp; the selector is added to the script name. If no sling:resourceType has been defined then: the content path will be used to search for an appropriate script (if the path based ResourceTypeProvider is active). For example, the script for ../content/corporate/jobs/developer.html would generate a search in /apps/content/corporate/jobs/. the primary node type will be used. If no script is found at all then the default script will be used. The default rendition is currently supported as plain text (.txt), HTML (.html) and JSON (.json), all of which will list the node's properties (suitably formatted). The default rendition for the extension .res, or requests without a request extension, is to spool the resource (where possible). For http error handling (codes 403 or 404) Sling will look for a script at either: the location /apps/sling/servlet/errorhandler for customized scripts or the location of the standard scripts /libs/sling/servlet/errorhandler/403.esp, or 404.esp respectively.
So ... taking the first statement, if I use .json as the extension as in :-
/content/corporate/jobs/developer.json
it would suggest that this script could be found :-
/apps/hr/jobs/jobs.json.jsp
or even just:
/apps/hr/jobs/json.jsp
but doing that just results in default json render being called.
WHY AREN'T EITHER OF THE ABOVE SCRIPTS USED IF THEY ARE AVAILABLE IN THE FOLDER /apps/hr/jobs ???
Any attempt to use a selector as well as the json extension :-
/content/corporate/jobs/developer.print.json
causes :-
Invalid recursion selector value 'print'
Thoroughly confused !
Regards
Fraser.