www.webdeveloper.com
Results 1 to 5 of 5

Thread: encoding a stringbuffer

  1. #1
    Join Date
    Jan 2003
    Location
    PA
    Posts
    1,898

    Question encoding a stringbuffer

    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();
    Thanks!

  2. #2
    Join Date
    Dec 2002
    Location
    Calgary, Canada
    Posts
    6,119
    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
    Cheers

    Khalid

    Message Posting Guidelines In These Forums, Please read these before posting any question.
    Web site: webapplikations.com
    Web Resources Page:Web Resources

  3. #3
    Join Date
    Jan 2003
    Location
    PA
    Posts
    1,898
    I just got this working yesterdY, thanks.

  4. #4
    Join Date
    Dec 2002
    Location
    Calgary, Canada
    Posts
    6,119
    Hey, It helps others who may end seeing your thread with similar issues, I think its nice to put your solution for others benefit.
    Cheers

    Khalid

    Message Posting Guidelines In These Forums, Please read these before posting any question.
    Web site: webapplikations.com
    Web Resources Page:Web Resources

  5. #5
    Join Date
    Jan 2003
    Location
    PA
    Posts
    1,898
    Sorry, the fix was I was missing an ending tag.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles