サンプルじゃよー。

[ 戻る ]


<html>
<head>
</head>

<%!
private String encode(String inToken) {
  int i;
  char ch;
  StringBuffer outSbuf = new StringBuffer();
  for ( i = 0 ; i < inToken.length() ; i++ ) {
    ch = inToken.charAt(i);
    if ( ch == '>' ) { // 
      outSbuf.append("&gt;");
    } else if ( ch == '<' ) {
      outSbuf.append("&lt;");
    } else if ( ch == '"' ) { 
      outSbuf.append("&quot;");
    } else if ( ch == '&' ) { 
      outSbuf.append("&amp;");
    } else {
      outSbuf.append(ch);
    }
  }
  return outSbuf.toString();
}
%>

<body>
<HR>
<%= encode("><\"&") %> <%-- こんな感じ --%>
<HR>

</body>
</html>