I have a huge JSON that need to be rendered using response.getwriter.write() using a JSP. After getting the parsed JSON using gson , when I am trying to render the JSON using response.getwriter.write() , I am getting a line break in generated output and thus making the JSON invalid. I have checked this line break is coming when the JSON size is getting huge. Can you please help , how to fix this issue.
Asked
Active
Viewed 240 times
1 Answers
0
Review your JSP and check if there are any link break between tags. For example, there is a link break between <%@page language="java" %>
and <%@page import=" java.util.*" %>
<%@page language="java" %>
<%@page import=" java.util.*" %><%@page import=" java.io.*" %><%
response.setContentType("text/plain;charset=UTF-8");
response.getWriter().write("...");
%>
<% //there is another new line char between scriptlet tags.
%>
Another way is check the .java/.class file generated by server. For Tomcat, check the answer of Where are compiled JSP Java (*__jsp.java) files?