Calling Service in component
Hi,
I am trying to call Service from my component and my service return json data, but when I am trying to call the service from Component , I am getting error.Please let me know how can I call the json data in my component jsp.
Please find attached my interface and implementation class.I am trying to call :
<%
com.petco.www.core.service.servlets.IContentService servicedata = sling.getService(com.petco.www.core.service.servlets.IContentService.class);
%>
<%=servicedata.getContent(String path)%>
CODE:
package com.abc.www.core.service.servlets;
import java.io.IOException;
import javax.jcr.RepositoryException;
import org.apache.sling.commons.json.JSONException;
import org.apache.sling.commons.json.JSONObject;
import com.petco.www.core.service.exceptions.ContentServiceExceptions;
/*
* This is an interface class to retrieve content from the AEM Services. This interface will be invoked by different channel
* to get content using AEM services
*
*/
public interface IContentService {
/**
* This method will be invoked to get the content from AEM services.
*
* @param pageType
* @param path
* @return String
*/
public JSONObject getContent(String path)
throws ContentServiceExceptions,RepositoryException,IOException,JSONException;
}