JSP Scripts

JSP Scripts or Servlets can be used to render components. According to the request processing rules of Sling, the name for the default script is:

<*componentname*>.jsp

global.jsp

The JSP script file global.jsp is used to provide quick access to specific objects (that is, to access content) to any JSP script file used to render a component.

Therefore global.jsp should be included in every component rendering JSP script where one or more of the objects provided in global.jsp are used.

The location of the default global.jsp is:

/libs/foundation/global.jsp

NOTE
The path /libs/wcm/global.jsp, which was used by the versions CQ 5.3 and earlier, is now obsolete.

Function of global.jsp, used APIs, and Taglibs

The following lists the most important objects provided from the default global.jsp:

Summary:

  • <cq:defineObjects />

    • slingRequest - The wrapped Request Object ( SlingHttpServletRequest).
    • slingResponse - The wrapped Response Object ( SlingHttpServletResponse).
    • resource - The Sling Resource Object ( slingRequest.getResource();).
    • resourceResolver - The Sling Resource Resolver Object ( slingRequest.getResoucreResolver();).
    • currentNode - The resolved JCR node for the request.
    • log - The Default logger ().
    • sling - The Sling script helper.
    • properties - The properties of the addressed resource ( resource.adaptTo(ValueMap.class);).
    • pageProperties - The properties of the page of the addressed resource.
    • pageManager - The page manager for accessing AEM content pages ( resourceResolver.adaptTo(PageManager.class);).
    • component - The component object of the current AEM component.
    • designer - The Designer object for retrieving design information ( resourceResolver.adaptTo(Designer.class);).
    • currentDesign - The design of the addressed resource.
    • currentStyle - The style of the addressed resource.