Win a copy of Java Persistence with Spring Data and Hibernate this week in the Spring 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

enter key creats problem on JSP

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43075
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 2910
150
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
I yam what I yam and that's all that I yam - the great philosopher Popeye. Tiny ad:
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic