fieldAccessListener = null;
BodyContent bodyContent = getBodyContent();
String oldBody = bodyContent.getString();
StringWriter newBody = new StringWriter();
LazyWriter newBodyLazy = new LazyWriter((HttpServletRequest) pageContext.getRequest(), newBody);
int beginAt;
int endAt = 0;
try {
while ((beginAt = oldBody.indexOf(FIELD_ACCESS_MARKER_BEGIN, endAt)) > -1) {
newBodyLazy.write(oldBody.substring(endAt, beginAt));
endAt = oldBody.indexOf(FIELD_ACCESS_MARKER_END, beginAt);
if (endAt > -1) {
newBodyLazy.writeLazily(oldBody.substring(beginAt + FIELD_ACCESS_MARKER_BEGIN.length(), endAt));
endAt += FIELD_ACCESS_MARKER_END.length();
} else {
newBodyLazy.write(oldBody.substring(beginAt, beginAt + FIELD_ACCESS_MARKER_BEGIN.length()));
endAt = beginAt + FIELD_ACCESS_MARKER_BEGIN.length();
}
}
newBodyLazy.write(oldBody.substring(endAt));
newBodyLazy.writePending();
bodyContent.clearBody();
bodyContent.write(newBody.toString());
} catch (IOException error) {
// Should never happen when writing to StringWriter.