Link to home
Start Free TrialLog in
Avatar of msasikala
msasikala

asked on

display quotation marks in a text field in jsp

Hi,
  Iam getting data from data base and displaying it in a text field in jsp.but the data is getting truncated whenever a quotation mark (") is encountered.My code is
<input type="text" name="txt_Description" class="textBox100" value=<%=itemRec[2]%>      >

suppose  itemRec[2] = test"quot"only, this is displayed as test"quot" and the other part is getting truncated.can any one pls help me this is very urgent
Avatar of jimmack
jimmack

You could do:

value="<%= itemRec[2].replaceAll("\"", "&quot;") %>
Sorry, missed the closing quote of my own there ;-)

value="<%= itemRec[2].replaceAll("\"", "&quot;") %>"
Avatar of msasikala

ASKER

Hi,
  I tried this but I'm getting the following error

cannot resolve symbol
probably occurred due to an error in /GloboWorksDev/En/PurchaseOrder/Create/PRPOUpdate.jsp line 789:
class="textBox100" value="<%= itemRec[2].replaceAll("\"", "&quot;") %>" >
I think there is no replaceAll(string,string) in jsp for a string and if I'm trying with replace() it is giving error as

replace(char,char) in java.lang.String cannot be applied to (java.lang.String,java.lang.String)
probably occurred due to an error in /GloboWorksDev/En/PurchaseOrder/Create/PRPOUpdate.jsp line 789:
class="textBox100" value="<%= itemRec[2].replace("\"", "&quot;") %>" >
 
can u pls suggest the solution
Are you using JDK1.4?  If not, then we need a different solution ;-)

If you are confident that no apostrophe's will appear in the text, you could use:

value='<%= itemRec[2] %>'
I'm not using JDK1.4 ,I'm using JDK1.3.1 and there is quite a possibility that  I may get apostrophe's also in the text
ASKER CERTIFIED SOLUTION
Avatar of Kuldeepchaturvedi
Kuldeepchaturvedi
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Like the man says ;-)
Hi,
  this is working fine for all the charactrers except for apostrophe's .whenever an apostrophe is encountered it is displayed as &apos;

Ex: de'm'o is displayed as de&apos;m&apos;o

how shld this be handled?
That is strange!! If every other character is being converted properly, then this is also suppose to work.......
I will do some testing on my own box and will let you know.......
The same &apos happened to me.

Instead of using &apos;, try using &#39;
Avatar of Michel Plungjan
1. &apos; is not recognised in IE
2. &#39; IS recognised but in UTF-8 pages converted straight back to single quote, messing up my javascript.
Any ideas?