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>
Jawa
  • 2,336
  • 6
  • 34
  • 39

2 Answers2

0

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

Regards.

ATorras
  • 4,073
  • 2
  • 32
  • 39
  • Perhaps so. Any suggestions where to do the encoding? There is no escaping-related attribute in jsp:include, which would suit better than perfectly... – Jawa Sep 25 '09 at 12:34
  • 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. – Jawa Oct 08 '09 at 06:36
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.

Jawa
  • 2,336
  • 6
  • 34
  • 39