File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Struts converts input characters to HTML entities on post? 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 » Frameworks » Struts
Bookmark "Struts converts input characters to HTML entities on post?" Watch "Struts converts input characters to HTML entities on post?" New topic
Author

Struts converts input characters to HTML entities on post?

Diego Camargo Prates
Greenhorn

Joined: Nov 09, 2005
Posts: 2
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

Joined: Dec 13, 2004
Posts: 429
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

Joined: Nov 09, 2005
Posts: 2
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 ]
 
wood burning stoves
 
subject: Struts converts input characters to HTML entities on post?