0

I'm using jsp:include inside json-taglib's json:property element. The problem with this is that all HTML elements from included JSP page gets stripped at some point and only plain text remains. I have already stripped all newlines so the result shoud be valid JSON data.

How do I get full HTML returned by json-taglib?

Below is a snippet demonstrating the situation.

<%@ page language="java" %>
<%@ page pageEncoding="UTF-8" %>
<%@ page contentType="text/html; charset=UTF-8" %>

<%@ taglib uri="http://www.atg.com/taglibs/json" prefix="json" %>

<json:object>
  <json:property name="id" value="${element.id}" />
  <json:property name="html" escapeXml="false">
    <jsp:include page="/templates/generate-component.jsp">
      <jsp:param name="element_id" value="${element.id}" />
    </jsp:include>
  </json:property>
</json:object>

2 Answers 2

0

Maybe you should encode the data passed to json-taglib.

Regards.

Sign up to request clarification or add additional context in comments.

2 Comments

Perhaps so. Any suggestions where to do the encoding? There is no escaping-related attribute in jsp:include, which would suit better than perfectly...
IIRC, escapeXml="true" works on the directly included page but fails with the nested includes. Plus then the JSON data must be manually unescaped in javascript, which is a bit cumbersome.
0

One solution is to wrap the jsp:include in <c:out> tag and (mis)use the body-as-default-value, like so:

<c:out value="${null}">
  <jsp:include ...>
    <jsp:param ... />
  </jsp:include>
</c:out>

However, this won't work in a situation where the included JSP itself uses jsp:include.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.