Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts converts input characters to HTML entities on post?

 
Diego Camargo Prates
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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 ]
 
Yuriy Zilbergleyt
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
  • 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
  • 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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic