1 16 package org.apache.taglibs.dbtags.statement; 17 18 import java.io.IOException ; 19 20 import javax.servlet.jsp.JspTagException ; 21 import javax.servlet.jsp.JspWriter ; 22 import javax.servlet.jsp.tagext.BodyTagSupport ; 23 24 39 public class EscapeSQLTag extends BodyTagSupport { 40 41 public int doEndTag() throws JspTagException { 42 String unescaped = getBodyContent().getString(); 43 char[] unescapedChars = new char[unescaped.length()]; 44 unescaped.getChars(0,unescaped.length(),unescapedChars,0); 45 JspWriter output = pageContext.getOut(); 46 47 try { 48 for (int i = 0; i < unescapedChars.length; ++i) { 49 switch (unescapedChars[i]) { 50 case ('\''): 51 output.print('\''); 52 default: 53 output.print(unescapedChars[i]); 54 } 55 } 56 } catch (IOException e) { 57 throw new JspTagException (e.toString()); 58 } 59 60 return EVAL_PAGE; 61 } 62 63 } 64 | Popular Tags |