How to display special HTML characters in JSP inputText form fields?
843840Mar 3 2008 — edited Mar 3 2008On my JSP webpage, input from a text box of a form is getting stored in an oracle database and is displayed in the same text box so that it can be re-edited.
Imagine the _'s aren't in what you're about to see. They're needed to stop the browser displaying the converted symbols.
Here's an example of my problem:
There don't seem to be too many characters that this happens with - the & symbol goes in as & and © is stored in the database as © so they're not a problem, but some characters such as *<* are being escaped and entered into the database as *&_lt;*
When the value is retrieved from the database to be displayed in the form field, e.g. <h:inputText value="#{...}"></h:inputText>, the *&* of the *&_lt;* is encoded as *&_amp;* so what gets entered into the source code of the page is *&_amp;lt;* and the browser renders that as *&_lt;* in my form text field. I want it to display the character that was originally entered, *<*.
If I manually enter < into the database (so instead of &_lt;) it is rendered fine in my browser. Does anyone know how I can stop the characters being converted to their HTML codes before they're entered into the database?
Thanks.