Coding for CQ/WEM can be quite confusing sometimes, as confusing as it is whether it's CQ or WEM. This post is about basic WEM Code samples (in JSP) using CQ scripting objects on top of JSP implicit objects. First of all, let me be clear, since Adobe acquired Day Software, the name of Day CQ (Comuniqué) had changed to WEM (Web Experience Manager), thus CQ and WEM are interchangeable.
When you develop the jsp script of a AEM component, most of the cases you'd include following code at the top of the JSP script:
It declares and exposes the regularly used scripting objects defined by the sling taglibs, cq taglibs and jstl taglibs at your disposal in JSP. Assuming you have the above line in your .jsp, the following code samples show you some very basic tasks that you usually have to accomplish.
Access Current Resource and Its Properties
Most of the time, you'd access the current page, current component, current whatever, etc. The global.jsp brings many exposed variable to you to access current resource via EL expression:
<h1>display the name of the component</h2>
 "propertyName" is the property name of the jcr:content node of the current page.
Locate a Specific Sling Resource
If you'd like to access Resource other than current node, component, page, etc. but instead need to access property of a non-current resource. How would you code that?
CQ is both JCR and Sling. JCR are about Node and Property, whereas Sling assumes everything is a Resource which is adaptable to other classes. To find Resource(s), use ResourceResolver:
 The xpath syntax to match resources that has property named 'transporUri'.
Access Property of a Specific Resource Path
Once you have a Resource, you can adapt a Resource to a Page, adapt a Resource to a ValueMap, a Node, or an InputStream, etc., then access the ValueMap for the property value. In your JSP file, do this:
 The ValueMap is an easy way to access properties of a resource.
 If you ever need to deal with JCR node directly.
Access HTTP Sling Request
From a slingRequest, you can get the URL in string presentation, or get the path information about the sling resource's path, selector, extension, suffix, etc.
 e.g., path = '/content/public/estate/estate-administration/checklist-the-executor-s-role/jcr:content', selectorString = 'download', extension='pdf', suffix='null'