• 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

Struts converts input characters to HTML entities on post?

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

I'm having some trouble in getting this to work, so any help including pointers to documentation would be really appreciated.

When I submit specific characters (like ampersand, quote)from my JSP page to the server, I get them translated to HTML entities automatically. I suppose this is being done automatically by Struts, between the JSP form submission and the form population.

This is what I get:

Submit "&", the ActionForm property shows "&".
Submit ">", the ActionForm property shows ">gt;".

This is a problem considering we have fixed-length database columns. Thus, client-side string sized 1 is translated to a server-side string sized 4, 5 or 6, bringing obvious storage problems.

Is there any way to tell Struts to put the strings exacly the way they were typed in the page form? Otherwise, I'd need to manually convert back those HTML entities to ASCII characters. There is a similar feature in the <bean:write> tag, the attribute "filter", but this is only for output.

Again, any help on this would be very appreciated.

Thanks and regards,
Diego.

[ November 09, 2005: Message edited by: Diego Camargo Prates ]
[ November 09, 2005: Message edited by: Diego Camargo Prates ]
 
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The HTML entities are used in the generated HTML, but are they actually used inside the Java code? Inside your action class, try doing a System.out.println() of the form field in question.

Yuriy
 
Diego Camargo Prates
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, the Java String inside the action form holds the value as HTML entity. I mean, the value inside the property is "&amp;", not "&" as desired.
[ November 11, 2005: Message edited by: Diego Camargo Prates ]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic