Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to display special HTML characters in JSP inputText form fields?

843840Mar 3 2008 — edited Mar 3 2008
On 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 &copy; is stored in the database as &copy; 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.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 31 2008
Added on Mar 3 2008
1 comment
145 views