Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

enter key creats problem on JSP

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

i am facing problem with enter key . I have an image and i call a finction on onclick event. In this function a value prviously stored in database is being passed as argument(value is text content).
but when i get enter key in text content it gives unterminated string constant.



Thanks in advance
 
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Post the HTML that gets generated by that JSP snippet. My guess would be that the value of WSR_ATTR1_VAL contains unescaped single or double quotes.
 
suchit pandya
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


it is coming like this in view source.
because on \n "ff"goes in new line.

can we decode encode \n by any escape character or any there way??
 
suchit pandya
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for posting i solved it.

by replacing \r\n of the string by /r and then re replace /r by \r\n in called function.
 
Bartender
Posts: 2697
130
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

suchit pandya wrote:Thanks for posting i solved it.

by replacing \r\n of the string by /r and then re replace /r by \r\n in called function.



I suggest a different way would be to convert:

\r\n to \\r\\n

which will make the output:
<td width="5%" align="center" class='label3'>

<img src="/IWAS/FMS/images/vwicn116.gif" onclick="showComments('no comments\r\nff');">

I wonder if \r makes sense in js though...
reply
    Bookmark Topic Watch Topic
  • New Topic