Calling Service method in component
I have created interface IContentService and implemented that interface in java class ContentService.java.I need to call the method of java class inside my component.
public interface IContentService {
public JSONObject getContent(String path)
throws ContentServiceExceptions,RepositoryException,IOException,JSONException;
}
The method in my java class returns the value in the form of JSON format.I want that JSON format data to be displayed through my component.I can able to display the JSON response by hitting the service url,"http://localhost:4502/api/contentservice?pagetype=mspot&path=/content/pagename".But I want to display the JSON response by calling the service in my component.I have tried by calling the service by following it is throwing error,
<%
com.aaa.www.core.service.servlets.IContentService contentService = sling.getService(com.aaa.www.core.service.servlets.IContentService.class);
JSONObject ff = contentService.getContent(String path);
%>
<h3>The value of the key is: <%=ff%></h3>