| Author |
Encoding and decoding TextArea contents
|
Parthasarathy Venkatavaradhan
Greenhorn
Joined: Oct 10, 2002
Posts: 8
|
|
Hi, I have text area where the user can enter any ascii character. I am retrieving them through my JSP code and storing it in the Database. when i try to retrive from DB and return it as an HTML page, how do i preserve the characters so that the formatting is as entered by the user. This includes newline, spaces, ''', '""' etc... Thanks for the help in advance. Parthasarathy
|
 |
Tim Baker
Ranch Hand
Joined: Oct 04, 2003
Posts: 541
|
|
ok so when you enter the data in the DB using SQL make sure you use a PreparedStatement. This will then escape any characters that might intererfere with the SQL syntax. You do not need to deal with any of the encoding and decoding of the characters through the HTTP transfer because your container will do that. If you are displaying it as text in HTML then you will need to convert newlines in to <br /> which you can do by just using the String replaceAll method or of course just use the HTML <pre> tag to wrap the whole thing. If you are displaying it in another text area you dont need to wory about that.
|
Kim Jong II (North Korea's Dear Leader) said:Nuclear weapons don't kill people, people kill people.
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26144
|
|
Also, make sure you have the wrap attribute set to hard to preserve the linebreaks, tabs, ...
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
 |
|
|
subject: Encoding and decoding TextArea contents
|
|
|