This week's giveaway is in the Spring forum.
We're giving away four copies of Microservices Testing (Live Project) and have Chris Love & Andres Sacco on-line!
See this thread for details.
Win a copy of Microservices Testing (Live Project) 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

'&' missing while displaying Textbox values in JSP/jquery/javascript

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am getting some weired behaviour for below case.
Please help if anybody knows this issue.
I have jsp with texbox,I click next it will confirm the inputs on cofiramtion page and then submit.

In jsp when I enter any string with '&',its behaviour is as below.

abc & def --->abc & def
abc & def & -->abc & def
abc&def&ghi--> abc&def
abc&def&ghi & test-->abc&def&ghi & test

Means when I enter string with '&' without space the string/character after last '&' is
missing on the confirmation page.I am using jquery/javascript to display information on confirmation page.

Please help ..
Thanks!!
ssn
 
S Nikam
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Got the solution for this

var name1 = document.getElementById(name).value;
name1 = name1.replace(/\&/g,'&');;
element1.innerHTML =name1

Thanks
ssn
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You do realise that & is a special character in HTML?

It should be encoded as & in any html.

The JSTL <c:out> tag will do that for you automagically.

& is also a special character in urls (used to seperate parameters). however if you are submitting a form, then that should be escaped automatically for you as well.
If you are building up the url string yourself, make sure you URLEncode any parameter values, which will escape the & characters.

Also note that to write &amp; on this forum you write it as &amp;amp;

 
reply
    Bookmark Topic Watch Topic
  • New Topic