hi,
i want to replace a single quote with double quotes in a string for inserting into a
database table(using CallableStatement). i found the following code in javaguru.
=============
private String sqlEncode(String a_str){
int index = -1;
index = a_str.indexOf('\'');
if (index == -1)
return a_str;
int start = 0;
while (index != -1) {
a_str = a_str.substring(0, index + 1) + "'" + a_str.substring(index + 1);
start = index + 2;
index = a_str.indexOf('\'', start);
}
return a_str;
}
=============
But i don't know how to use the above code in my jsp program(i am new to jsp and
java). do i have to create a bean to use the above code? Suppose if i have only the
following code in my jsp program and i want to use the above code to print "Ramesh''s
program", how do i do that?
<%
String msg = "Ramesh's program";
//here i want to use the code
out.println (msg);
%>
thanks,
Ramesh Kadirisani.
===========================================================================
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://archives.java.sun.com/jsp-interest.html
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.jsp
http://www.jguru.com/faq/index.jsp
http://www.jspinsider.com