Hi there,

That's obvious...all developpers already know that.

I made methods below to validate...

// Check if all string contains illegal characters(single quote ' ,
double quote " ,
< , > ). if so, add \ in front of those characters.
public String parse_illegal_char(String info){

        String after = "";
        if(info!=null){
                if(info.length() > 0){
                        StringTokenizer st = new StringTokenizer(info,"<>",false);
                        info="";
                        while(st.hasMoreTokens()){
                                info = info + st.nextToken();
                        }
                }

                StringTokenizer st = new StringTokenizer(info,"'",false);
                while(st.hasMoreTokens()){
                        after = after + st.nextToken() + "\\'";
                }
                if(after.endsWith("\\'")){
                        after = after.substring(0,after.length() - 2);
                }

                st = new StringTokenizer(after,"\"",false);
                after = "";
                while(st.hasMoreTokens()){
                        after = after + st.nextToken() + "\\\"";
                }
                if(after.endsWith("\\\"")){
                        after = after.substring(0,after.length() - 2);
                }
        }

        return after;

}

// < and > are for HTML or script... Actually, remove only either < or >
is fine...


Best regards,
Fumitada.

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to