• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

& escape problem in HTML controls

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

I've noticed a discrepancy in how the & character is escaped in the <option and <input control statements in a Java 1.4.2 JSP page. Trying to display the string AT&T as the value in an <option HTML control statement displays AT&T as I expect but the same string in an <input HTML control statement returns AT. If the string is A & P Co then the <option HTML control statement displays A & P Co, again as expected. However the <input HTML control statement displays the string as A & P Co.

<select onchange='changeShownRecord(this);' name='vendor_name' size='1'>
<option value='604'>AT&T</option></select>
vs
<input type='text' name='vendor_name' size='35' maxlength='50' value=''/>

where vendor_name is the bean element containing the string (in this case AT&T).

I seems like there is some type of character encoding being performed but I don't if there is any way to control it. Can escaping be controlled or am I doing something wrong using the HTML control statements? Thanks in advance.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To be honest, I can't really tell what your issue is from what you've posted. But the & is the introductory character for HTML entities and you must be cautious when using it. To display an ampersand use the HTML entity &amp;
reply
    Bookmark Topic Watch Topic
  • New Topic