This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes JSP and the fly likes '&' missing while displaying Textbox values in JSP/jquery/javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » JSP
Bookmark " Watch " New topic
Author

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

S Nikam
Greenhorn

Joined: Dec 28, 2010
Posts: 11
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

Joined: Dec 28, 2010
Posts: 11
Got the solution for this

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

Thanks
ssn
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1018
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;

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: '&' missing while displaying Textbox values in JSP/jquery/javascript