Re: Strange Struts 7 Tag Limit Issue
Zoran Avtarovski <[email protected]> Mon, 20 Oct 2025 09:18:09 +1100
| Newsgroups | gmane.comp.jakarta.struts.user |
|---|---|
| Message-ID | <[email protected]> |
Thanks Lukasz, In the end it turned out to be the Javamelody filter which created the=20 issue. We'll do some more digging to see if we can resolve but we are=20 happy to disable javamelody for now to finally move to testing using=20 7.1.1 and Tomcat 11. Z. On 18/10/2025 9:52 pm, Lukasz Lenart wrote: > I used Claude Code to analyze this problem and I got a big document > (attached), but you can try this for now: > > - [ ] Enable WARN logging for > `org.apache.struts2.util.FastByteArrayOutputStream` > - [ ] Reproduce the truncation and check logs for encoding warnings > - [ ] Identify the exact character position where truncation occurs > - [ ] Examine the character(s) at and immediately after the truncation = point > - [ ] Verify `struts.i18n.encoding` is set to "UTF-8" > - [ ] Verify JSP `pageEncoding` and `contentType` both specify "UTF-8" > - [ ] Check if SiteMesh is decorating the JSON response (should be excl= uded) > - [ ] Compare `response.getCharacterEncoding()` between Tomcat 10 and T= omcat 11 > - [ ] Test with JSON plugin instead of JSP rendering > - [ ] Check for any custom filters or interceptors that wrap the respon= se > > Cheers > =C5=81ukasz > > sob., 18 pa=C5=BA 2025 o 04:12 Zoran Avtarovski <[email protected]= m> napisa=C5=82(a): >> Hi Guys, >> >> We are almost ready to go into final testing on our Struts 7 app >> migration, except for a small issue when we render JSON responses and = we >> can't work out where the issue is. >> >> The problem presents when we try and render JSON response to a jsp pag= e, >> but only when going through an action first. I should stress this work= s >> fine on tomcat 10 using the same build of Struts and SiteMesh. >> >> As a simple test we created a method on our action class which sets a >> page accessible parameter to a long sample JSON string: >> >> public String ajaxTest(){ >> ajaxResponse =3D " [{\"name\": \"Adeel >> Solangi\",\"language\": \"Sindhi\",\"id\": \"V59OF92YF627HFY0\",\"bio\= ": >> ... I have attached the full JSON text but cropped in the email for cl= arity >> return SUCCESS; >> } >> >> On the resulting jsp page, see below, it results in the JSON string >> being cropped and the browser complaining of invalid JSON: >> >> <%@ page contentType=3D"application/json; charset=3DUTF-8" %> >> <%@ taglib prefix=3D"s" uri=3D"/struts-tags"%><s:property >> value=3D"%{ajaxResponse}" escapeHtml=3D"false"/> >> >> We also tried using JSTL tags which has the same result: >> >> <%@ page contentType=3D"application/json; charset=3DUTF-8" %><%@ tagli= b >> uri=3D"jakarta.tags.core" prefix=3D"c"%><c:out value=3D"${ajaxResponse= }" >> escapeXml=3D"false"/> >> >> The strange part is if we set the variable in the JSP page and just ca= ll >> the page directly via testPage.jsp it works as expected: >> >> <%@ page contentType=3D"text/html;charset=3DUTF-8" language=3D"java" >> pageEncoding=3D"UTF-8"%> >> <%@ taglib prefix=3D"s" uri=3D"/struts-tags"%> >> <s:set var=3D"ajaxText"> >> [{"name": "Adeel Solangi","language": "Sindhi","id": >> "V59OF92YF627HFY0","bio": "Donec lobortis eleifend condimentum. ... >> </s:set> >> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" >> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> >> <html xmlns=3D"http://www.w3.org/1999/xhtml" xml:lang=3D"en" lang=3D"e= n"> >> <head> >> <title>SpareEngine</title> >> <meta http-equiv=3D"Content-Type" content=3D"text/html;chars= et=3Dutf8" /> >> </head> >> <body> >> <div class=3D"main-body"> >> <s:property value=3D"%{ajaxText}" escapeHtml=3D"false"/> >> </div> >> </body> >> </html> >> >> Because the plain JSP renders correctly I don't think it is a tomcat >> issue, but I can't be certain. Any help would be appreciated. >> >> Z. >> >> >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [email protected] >> For additional commands, e-mail: [email protected] >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [email protected] >> For additional commands, e-mail: [email protected]