Servlet response is printing CQ related information
Hi,
I have written a servlet which calls OSGI service. And OSGI service invokes API and returns JSON response to servlet and servlet prints response on the page. But when printing servlet response on the page, CQ related information is getting printed. I'm not sure why. Can anyone please help me with this?
Below is my servlet code.
@8220494(service=Servlet.class,
property={
Constants.SERVICE_DESCRIPTION + "=Servlet to call API Url",
"sling.servlet.methods=" + HttpConstants.METHOD_GET,
"sling.servlet.resourceTypes="+ "aem-code/components/structure/page",
"sling.servlet.extensions=" + "txt"
})
public class CallApiServlet extends SlingSafeMethodsServlet {
private static final long serialVersionUID = 1L;
private static final Logger log = LoggerFactory.getLogger(CallApiServlet.class);
@3214626
private CallApiService apiCall;
@9944223
protected void doGet(final SlingHttpServletRequest req,
final SlingHttpServletResponse resp) throws ServletException, IOException {
resp.setContentType("application/json");
String result = apiCall.getApiData(req.getParameterMap());
log.info("called"+result); //Here the result is printing without CQ information
resp.getWriter().write(result);
}
}
my servlet response:
{"results":[{"name":{"title":"Ms","first":"Nalan","last":"Oraloğlu"},"login":{"uuid":"baffd062-6cc7-4dd5-b1fd-69d4cde0f845","username":"ticklishgorilla641","password":"zhan","salt":"VUD21uld","md5":"70b78925165996a5926af72b2cbe373d","sha1":"b50f720abecaa5cc9eed47724ddbf457cd501388","sha256":"d3cbfbb1990802e19467640376257db0f631755aaaf85afe9ce0b2925fa91970"},"nat":"TR"}],"info":{"seed":"05d85febdd32196c","results":1,"page":1,"version":"1.3"}}
<!--cq{"decorated":false,"type":"aem-code-challenge/components/structure/page","path":"/content/aem-code-challenge/en/jcr:content","selectors":"txt","servlet":"CallApiServlet","totalTime":114,"selfTime":114}-->
The above CQ information is getting printed which is not required.
Thank you!