Sunday, September 15, 2013

How to get Service in JSP?

Below are the two easiest ways to get Service:

1. Using the slingScriptHelper     

<sling:defineObjects />


      ServiceType service = sling.getService(ServiceType.class);


2. Using adaptTo()

adaptTo() method that will translate the object to the class type being passed as the argument.


Node node = resource.adaptTo(Node.class);

More Info on Adaptors:

No comments:

Post a Comment