File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes hashmap problem with special character Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "hashmap problem with special character" Watch "hashmap problem with special character" New topic

hashmap problem with special character

patni pat

Joined: Nov 28, 2012
Posts: 5
i am using hashmap under starus tag <s:textfield> passing map key as <s:textfield name="quantityMap['%{#productData.code}']" />.. this should store the quantity(passed in textfield) against productcode. in model its working fine for a normal scenario, but when map key contains "#" like if my productcode is"ADC#3" then its not working at all.

please help
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46337
Welcome to the Ranch

You would have to provide more details; we cannot tell what is not working.
I cannot see why a Map should have difficulty taking a String with the hash sign # in. I suggest you precede each put(...) call by a line which prints out the key and value. See whether the key is reaching the Map in the same form that it left your HTML file. Are you sure it is the # character rather than quotes which is causing the trouble?
patni pat

Joined: Nov 28, 2012
Posts: 5
thanks for reply,

there is not any problem of quote because its working fine with other data in same iterator,

i am getting error
WARN [OgnlValueStack] Error setting value
INFO ognl.OgnlException: target is null for setProperty(null, "addtobasket", [Ljava.lang.String;@7d1fae)
INFO | jvm 1 | main | 2012/11/29 14:24:59.190 |

is it the problem of struts textfield or ognl which may not accept "#" in name or id
Winston Gutkowski

Joined: Mar 17, 2011
Posts: 8927

patni pat wrote:is it the problem of struts textfield or ognl which may not accept "#" in name or id

Again, without a proper SSCCE, we really have no idea, but what I can tell you is that those are NOT Java error messages.

Like Campbell said: TellTheDetails (←click).


Bats fly at night, 'cause they aren't we. And if we tried, we'd hit a tree -- Ogden Nash (or should've been).
Articles by Winston can be found here
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

Since this seems to be particularly about Struts (does the # character mean something special in Struts? I don't know) then let's put it in the Struts forum where it might get looked at by people who know that.
I agree. Here's the link:
subject: hashmap problem with special character
It's not a secret anymore!