Bookmark Topic Watch Topic
  • New Topic

double quotes handling  RSS feed

 
chetana kotamreddy
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Report post to moderator
I am facing a problem with the lookup button. If the user clicks on lookup button by giving some search text,all the results should be fetched from the data base and should be displayed in a pop up window.In the jsp, the results are fetched from the database and are being displayed. In the data that is fetched, double quotes are present which is giving the java script error. So, in the action class, i have written a method to handle the double quotes ie i have appended / character to the data before the double quotes to escape it. Now the javascript error problem is resolved but in the popup window, / character is also displayed. Can any one suggest.

<logic:iterate id="resultItem" name="results" type="com.test.model.custom.TestSampleData" indexId="index">
resultsArray[<%=index%>] = new ResultItem(
"<bean:write name="resultItem" property="userId"/>",
"<%=((com.test.model.custom.TestSampleData)resultItem).getUserName()%>",

);
</logic:iterate>

This is the jsp where the name is fetched from TestSampleData class which is containing the double quotes. So, uin the Action class only, i have appeneded the / character before the double quotes. Also note when i select the results, to the main page / character is not getting displayed.

Please suggest.....
 
Chris Beckey
Ranch Hand
Posts: 116
Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Report post to moderator
Maybe a typo, but did you mean slash '/' or backslash '\'. The escape character is backslash '\'. i.e.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Report post to moderator
See if the Apache StringEscapeUtils gives you some ideas. This kind of thing makes us absolutely crazy. Anybody here have good project-wide practices for handling special characters entered by the user, returned from data sources, etc? Escape everything always?
[ November 20, 2006: Message edited by: Stan James ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66306
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please do not cross-post the same question in multiple forums. It wastes people's time when multiple redundant conversations take place.
 
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!