abyin007
abyin007

Reputation: 401

Getting ® as ? when reading from Struts 2 JSP page

I have a JSP page where when I enter the value "®" inside the <s:textarea> and then when I sysout in action class its printing "?".

Even replacing code cant detect it as "?", ie

say i entered "XYZ ®" inside <s:textarea>

In action class sysout its printing "XYZ ?".

Now, if am using

value = value.replace("?", "QQQQQ");

Its not replacing.

But if i am giving "XYZ ?" in <s:textarea> then the replace code is working.

My requirement is that from <s:textarea> the content containing "®" should be accessible in Java action class as a string variable and should display the same in another JSP page.

Right now its printing "®" as "?".

Upvotes: 0

Views: 93

Answers (2)

Roman C
Roman C

Reputation: 1

The character should be escaped like &reg;.

You should always remember writing the HTML source code plainly in ASCII, instead of writing symbols, always write their ASCII equivalents.

Upvotes: 0

Vinay Lodha
Vinay Lodha

Reputation: 2223

Looks like it is because character is not recognized by encoding. To fix this you will need to change encoding to UTF-8 to make this work. Please refer this question

Upvotes: 1

Related Questions