double quotes problem in jsp while showing a string with " by <input value="<%=string%>">

    I 'm using PreparedStatement to insert records. There is no single quotes or double quotes problem while inserting the record. The string is found as such in database also. While retrieving the record and showing in the browser, the string after the double quotes is not found but its there in the table.
 
example:
string s=(Hello' world "welcome to jsp" );
 
if i bring back to screen from database thru HTML input tag
 
<input type="text" name="s" value="<%=s%>">
 
the string displayed in screen is Hello' world
 
"welcome to jsp" is not found.
 
deserve2000Asked:
Who is Participating?
 
SRF_01Connect With a Mentor Commented:
You could try an escape

eg
string s=(Hello' world \"welcome to jsp\" );
0
 
msa2003Commented:
Replace quotes and double quotes with \' and \" accordingly:

string s="Hello\' world \"welcome to jsp\"";
0
 
dfranksonCommented:
Are you using SQL Server?  If so, single quotes are special characters are need to be escaped when used in queries.  To escape them replace the single quote with two single quotes.

Example:  You are trying to find the word I'm in the database.

SELECT * FROM words WHERE word = 'I''m'
0
All Courses

From novice to tech pro — start learning today.