I have a StringBuffer that has html code in it, that eventually get's rendered on my page. I have an issue though, where my page no longer validates XHTML, and it points to the javascript code that is being rendered from my stringbuffer. I'm assuming I need to encode this stringbuffer, but how would I do that. Below is my code for generating the stringbuffer.
Code:
for (RhsElementList rhsElementList : rhsZones.getRhsZones()) {
if (rhsElementList.pagename.equalsIgnoreCase(rhsPage)) {
for (RhsElement rhsElement : rhsElementList.pages) {
logger.debug("Value of adUrl: " + rhsElement.getAdUrl());
rhsStringBuffer.append("<script type=\"text/javascript\">");
rhsStringBuffer.append("ord = window.ord || Math.floor(Math.random()*1E16);");
rhsStringBuffer.append("document.write('<script type=\"text/javascript\" ");
rhsStringBuffer.append("src=\"");
rhsStringBuffer.append(rhsElement.getAdUrl());
rhsStringBuffer.append(";ord=' + ord + '?\">");
rhsStringBuffer.append("<\\/script>');");
rhsStringBuffer.append("</script>");
rhsStringBuffer.append("<noscript>");
rhsStringBuffer.append("<a href=\"");
rhsStringBuffer.append(rhsElement.getAdUrl());
rhsStringBuffer.append(";ord=123456789?\" target=\"_blank\">");
rhsStringBuffer.append("<img src=\"");
rhsStringBuffer.append(rhsElement.getAdUrl());
rhsStringBuffer.append(";ord=123456789?\" alt=\"NEED ALT TEXT HERE\" />");
rhsStringBuffer.append("</a>");
rhsStringBuffer.append("</noscript>");
}
}
}
rhsItem = rhsStringBuffer.toString();
I dont think it has anything to do with encoding(initially), post your rendered html that you think is not being validated, I am certain your missing some brackets here and there
Bookmarks