aspose file tools
The moose likes HTML, CSS and JavaScript and the fly likes data characters that can break the html Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "data characters that can break the html" Watch "data characters that can break the html" New topic
Author

data characters that can break the html

Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2038
Hello,

(The data I will display is dynamic and will come from a database. It can contain special characters. I heard another team's html was broken by an & character, and I will also read that database and display its data.)

What characters can damage the html?
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15361
    
    6
When you input your data into the db it probably should be escaped/encoded.

Any character that can be in html markup. <>"'/\ etc

If you are not escapeing user input, I am sure there is a big security hole with JavaScript injection in your application.

Eric
Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2038
The data was formerly used primarily only in mainframe, i.e., CICS, batch jcl, etc. That is most likely the reason why this never became a problem.

Maybe a layer that translates between these 2 worlds will do. Like a utility class method that input the data from MVS and returns a web-friendly string.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56521
    
  14

If you are using a database, you are probably using a server-side language. If it is servlets and JSP then use of the JSTL <cut> action will automatically encode output properly.

I will disagree with Eric with regards to encoding the data sent to the database. That limits it usefulness for environments other than the web. The data should be encoded on output.
[ October 16, 2006: Message edited by: Bear Bibeault ]

[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2038
My installation is only J2EE 1.3.

I researched but not able to get an answer if JSTL is required by specs for containers to support, for J2EE 1.3.

Anyone know?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56521
    
  14

JSTL 1.0 is compatible with JSP 1.2, JSTL 1.1 is compatible with JSP 2.0.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56521
    
  14

Of course it would also be very easy to write your own custom tag to perform this encoding should you not wish to adopt JSTL.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: data characters that can break the html
 
Similar Threads
Submit formatted text with JSP and TinyMCE
Cant insert euro symbol
How to insert HTML into database?
Localisation in HTML
Japanese Text Not Dispaly