• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

double quotes handling in jsp

 
chetana kotamreddy
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the jsp code where i am facing the problem:

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

Here in the user name if double quotes are present in the database, java script error is coming.

Please help...
 
Rusty Smythe
Ranch Hand
Posts: 93
Mac Objective C Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where's the code to

((com.aon.concert.model.custom.IBISAccountData)resultItem).getUserName()

??? Your question is full of red herring, no details and you haven't shown the problem.

We can't help you if you don't give the required info...
 
chetana kotamreddy
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The data class contains only the getter and setter methods. So, i have not given the code.We are using to get the name of the user. So, in the Action class i am handling the double quotes by calling the escapeDoubleQuotes method in which i am appending \\\ characters to " to escape it. But in the pop up window \ is also displayed.

Here is teh code for escapeDoubleQuotes:

public static String escapeDoubleQuotes(String sourceString) {
int quotePos = 0;
StringBuffer formatStr = new StringBuffer("");
if(sourceString.indexOf('"',0) > -1){
quotePos = sourceString.indexOf('"',0);
formatStr.append(sourceString.substring(0,quotePos)).append("\\\"") ;
sourceString = sourceString.substring(quotePos+1,sourceString.length());
}
if (sourceString != "") formatStr.append(sourceString);
else {
formatStr.append(sourceString);
}
}

I am calling this method before i send the value to the data class. Now the double quote is not giving the javascript error, but in th epop up window \ character is also displayed. But when i select the record, in the main page ectra \ character is not getting displayed. Only the user name is displayed. Can you please suggest why \ character is displayed in the popup jsp.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic