How to escape apostrophe or quotes on a JSP (used by JavaScript)

I have a user form. If the user types in a string with `'` or `"` as part of it I have no problem. The form is submitted and saved correctly to the database. My problem is when I reload the page (all entries can be modified and are loaded into a list in the JSP before being displayed). On loading the page I get an error saying: missing ) after argument list 'Caroline's message', \n What do I need to do to escape this string for displaying it on the frontend? Here is the code I am using on the frontend to read in the data and store it in a JavaScript object. I am not fully sure where I need to escape. The field causing the problem is c.getComName: communications[<%=i%>][1] = new CommObject('<%=c.getComId()%>', '<%=c.getComName()%>'); **UPDATED WITH HTML GENERATED:** communications[0][1] = new CommObject('101', 'Caroline's Message');
What do you mean by messed up? In what way are those characters messed up?

以上就是How to escape apostrophe or quotes on a JSP (used by JavaScript)的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准