AEM inserts html info comment into json | Community
Skip to main content
yaraslaud208334
New Participant
October 16, 2015
Solved

AEM inserts html info comment into json

  • October 16, 2015
  • 3 replies
  • 1580 views

I have the following jsp

<% JSONObject jsonResult = new JSONObject(); response.setContentType("application/json"); String parentNodePath = slingRequest.getRequestPathInfo().getResourcePath(); String url = getServerBaseUrl(sling) + parentNodePath.split("/jcr:content")[0] + ".html?cid=twitter"; UrlShortener urlShortener = sling.getService(UrlShortener.class); String shortUrl = urlShortener.shorten(url); String encShortUrl = URLEncoder.encode(shortUrl); jsonResult.put("url", url); jsonResult.put("shortUrl", shortUrl); jsonResult.put("encShortUrl", encShortUrl); %> <%=jsonResult.toString()%>

 

It executed when I type in browser the following adresshttp://servername:port/path/to/page.urlshortener.html.jsp

As you see i have "application/json" contentType. Result must contain only json information, but there is html comment:

{ "url":"http://servername/content/betcom/test/test1/naps1.html?cid=twitter", "shortUrl":"http://servername/1E4sZYJ", "encShortUrl":"http%3A%2F%2Fservername%2F1E4sZYJ" } <!--cq{"decorated":false,"type":"app/components/page/newsarticlepage","path":"/content/app/test/test1/naps1/jcr:content","selectors":"urlshortener","servlet":script/apps/app/components/page/contentpage/urlshortener.html.jsp","totalTime":276,"selfTime":276}-->

Also i saw, this comments inserted after every component, or executed jsp in any page. How to turn off insertion of this comment?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by yaraslaud208334

There is no typo. I found two solutions

The first one is to replace http://servername:port/path/to/page.urlshortener.html with http://servername:port/path/to/page/jcr:content.urlshortener.html,

another one is to use additional parameter wcmmode=disabled

3 replies

joerghoh
Employee
October 16, 2015

Hi,

is the ".jsp" extension on your URL a typo? It shouldn't be there, just use "http://servername:port/path/to/page.urlshortener.html". Or even better ""http://servername:port/path/to/page.urlshortener.json" and make sure, that you put your JSP code in a JSP called "urlshortener.json.jsp".

kind regards,
Jörg

yaraslaud208334
yaraslaud208334AuthorAccepted solution
New Participant
October 16, 2015

There is no typo. I found two solutions

The first one is to replace http://servername:port/path/to/page.urlshortener.html with http://servername:port/path/to/page/jcr:content.urlshortener.html,

another one is to use additional parameter wcmmode=disabled

joerghoh
Employee
October 16, 2015

Hi

Yaraslau Dzenisiuk wrote...

There is no typo. I found two solutions

The first one is to replace http://servername:port/path/to/page.urlshortener.html with http://servername:port/path/to/page/jcr:content.urlshortener.html,

another one is to use additional parameter wcmmode=disabled

 

I would prefer the first one, as it creates static URLs, which is important in the publish usecase.

kind regards,
Jörg