Apostrophe not showing in Form input value

I have a JavaBean working great with Oracle 9i database using Tomcat 4.1.3 container where it shows Database values in a JSP update page that has a form for updating record information. The only issue is when I pull up in a JSP update form page where the field values are shown in the form input areas it doesnt show apostropes for the values. For example if the Oracle field value showsO'Reilly in the database, it will show asOReilly in the form value.If I pull up the value as just a text value in a Servlet Presentation page it shows as it should: O'Reilly

I am using a SQL Util method to replace apostrope in my Oracle SQL update and insert statements:

//SQLUtil class

publicstatic String encode(String s){

if (s ==null)return s;

StringBuffer sb =new StringBuffer(s);

for (int i = 0; i < sb.length(); i++){

char ch = sb.charAt(i);

if (ch == 39){// 39 is the ASCII code for an apostrophe

sb.insert(i++,"'");

}

}

return sb.toString();

}

SQL Update:

"UPDATE User "

+"SET EmailAddress = '" + SQLUtil.encode(user.getEmailAddress()) +"'"

+"FirstName = '" + SQLUtil.encode(user.getFirstName()) +"'"

+"LastName = '" + SQLUtil.encode(user.getLastName()) +"'"

+"WHERE EmailAddress = '"

+ SQLUtil.encode(user.getEmailAddress()) +"'";

Please advise.

[2259 byte] By [Evergreana] at [2007-11-27 8:48:21]
# 1
> > I am using a SQL Util method to replace apostrope inNo. Don't do that.Use PreparedStatements.
cotton.ma at 2007-7-12 20:55:09 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...