Hi Chris,
thanks for your help but I have still a doubt:
if I convert the input variable description I have to re-convert it again
when I want the real value.
For example, if description = abc "abc", I have to convert it to  abc
"abc"  to show it correctly on the web page and then,
I have to re-convert it again when I want the real value.

If the user insert description = abc" as real input value, the first
function will make any change (because the character " is not in the
variable) and then, the second function will convert the value to abc",
making a mistake.

Correct me if I'm wrong. Thanks for your answer.

Francesco





Chris Pratt <[EMAIL PROTECTED]>@JAVA.SUN.COM> on 16/07/2001 18.02.37

Please respond to A mailing list about Java Server Pages specification and
      reference <[EMAIL PROTECTED]>

Sent by:  A mailing list about Java Server Pages specification and
      reference <[EMAIL PROTECTED]>


To:   [EMAIL PROTECTED]
cc:
Subject:  Re: Please Help me.

You need to run it through some sort of filter that should change the <"&>
characters to &lt; &quot; &amp; &gt; respectively.  Try put a method
something like this somewhere on your class path.

public class Convert {

  /**
   * Convert sensitive characters in a string to their XML equivalents
   *
   * @param str String to be Processed
   * @return XML ready String
   */
  public static String toXML (String str) {
    char[] in = str.toCharArray();
    StringBuffer out = new StringBuffer(in.length);
    for(int i = 0;i < in.length;i++) {
      switch(in[i]) {
        case '<':
          out.append("&lt;");
          break;
        case '>':
          out.append("&gt;");
          break;
        case '\"':
          out.append("&quot;");
          break;
        case '&':
          out.append("&amp;");
          break;
        default:
          out.append(in[i]);
          break;
      }
    }
    return out.toString();
  } //toXML
}

then change your tag to look like

<INPUT TYPE="text" VALUE="<%=Convert.toXML(description)%>">

(*Chris*)


----- Original Message -----
From: "Gianfrancesco Martinico"
<[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, July 16, 2001 8:37 AM
Subject: [JSP-INTEREST] Please Help me.


> I have to manage an html statement as below:
>
> <INPUT TYPE="text" VALUE="<%=description%>">
>
> where description contains the character " (i.e. description= abc "abc").
>
> When I show the html page, I can only see the string truncated at the
first " character (i.e. abc ).
> How can I visualize the whole string, including " character?
>
> Thank you.
>
> Francesco
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
> 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


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
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

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
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