-1

In the textarea when I am putting the < and > characters in jsp, these characters got converted and reached to controller as &lt; and &gt;

Is there any way to get the same string at controller which we entered in textarea e.g "this is a < maths operator"? and not like "this is a &lt; maths operator"?

ABC
  • 4,263
  • 10
  • 45
  • 72
  • How do you know that the char is sent as `<` to the controller? It's not supposed to be encoded. – Olivier Jun 01 '21 at 18:21

3 Answers3

0

You can use the ascii table. for the '<' symbol the ascii number is 60 and for '>' the ascii number is 62.

0

You can use c:out's escapeXml="false" property like that:

<c:out value="${bean.property}" escapeXml="false" />

It is dangerous though as it opens the application up to XSS. More information could be found here: https://help.hcltechsw.com/commerce/8.0.0/developer/refs/rsdjspbpescapexml.html

Tarmo
  • 3,851
  • 2
  • 24
  • 41
  • Sorry This seems not working for me, Is there any way we can just pass the string in the textarea as is to the controller without being encoded e.g String in text area "This is < operator" , Can I get the same string at the controller and not like "This is < operator" – ABC Jun 01 '21 at 10:03
0

If you are still looking for the answer :
You can use HtmlUtils.htmlUnescape(sample_string); of org.springframework.web.util package

ProGamer
  • 420
  • 5
  • 16