*
The moose likes HTML, CSS and JavaScript and the fly likes Data in textarea is being interpreted as HTML by browser Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Data in textarea is being interpreted as HTML by browser" Watch "Data in textarea is being interpreted as HTML by browser" New topic
Author

Data in textarea is being interpreted as HTML by browser

Tom Katz
Ranch Hand

Joined: Aug 19, 2002
Posts: 169
I've got a JSP that's displaying any/all kinds of file data in a text area. Well, I just ran up against the occurrence where this file might be in xml-format, and it gets interpreted as HTML. What results is the </textarea> tag and everything below it is commented out.

Anyone seen this or know of a way to prevent a textarea from allowing this?

thanks
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
escape your server side code returned from the database. change all of the < to ↦lt; and > to &gt;

Eric
Tom Katz
Ranch Hand

Joined: Aug 19, 2002
Posts: 169
thanks...

I was just trying that with string.replaceAll("<", ">"), etc. Didnt seem to work, better check and make sure I'm doing it right ))
Tom Katz
Ranch Hand

Joined: Aug 19, 2002
Posts: 169
Oops that came out looking wrong because the < was interpreted as html. When I run the replaceAll on the string, it looks the same. Turns out though, removing a valid html comment below the textarea may have fixed this problem. Still got me worried tho...

thanks again
Ayan Kumar Roy
Greenhorn

Joined: Aug 21, 2002
Posts: 10
Can u please post the code?


Ayan Kumar Roy.<br />India
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Data in textarea is being interpreted as HTML by browser
 
Similar Threads
Reading HTML using JAVA
Problem with TEXTAREA
trouble with textarea
What things required to write generate multi lingual characters through Java
IDEA: web-based JSP editor for final markups...