I don't think there is a function you can call to convert
'<' into &lt; '>' into &gt; and '&' into &amp; I assume that
is what you are looking for.

I ended up writing a small function that loops thru a
StringBuffer and calls replace() to do the above
translation.

Good Luck
]Monty Shaw[

===code below====

    public static String encodeHTML(String x) {
        StringBuffer u = new StringBuffer(x.trim());
        // look for < and replace with &lt; etc.
        for (int i=0; i<u.length(); ++i) {
            char c = u.charAt(i);
            if (c == '<') {
                u.replace(i,i+1,"&lt;");
                i += 3;
            } else if (c == '>') {
                u.replace(i,i+1,"&gt;");
                i += 3;
            } else if (c == '&') {
                u.replace(i,i+1,"&amp;");
                i += 4;
            }
        }
        return u.toString();
    }

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to