Ramesh,
There is a rather handy function on a string called replace, it replaces
a certain character with another in a string.
In your code it would read:
<%
String msg = "Ramesh's program";
test.replace('\'', '"');
//here i want to use the code
out.println (msg);
%>
Best regards,
Peter Dolukhanov
-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]] On Behalf Of Ramesh Kadirisani
Sent: 16 July 2002 18:52
To: [EMAIL PROTECTED]
Subject: replacing a single quote with double quotes
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
===========================================================================
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