File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Escape all special characters in HTML Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Escape all special characters in HTML" Watch "Escape all special characters in HTML" New topic
Author

Escape all special characters in HTML

Scott Selikoff
author
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3716
    
    5

Hi All,

Is there a simple (built-in) method in java for escaping a string containing special characters to HTML? I came across this page which is useful but not complete. There's a couple hundred in this table that I would like to add. Right now, my only solution is to manually edit the text of the first page to include more of the codes of the second, but I feel like I'm re-inventing the wheel.

Is there a better way to do this?

-Scott


My Blog: Down Home Country Coding with Scott Selikoff
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31070
    
232

Scott,
Have you looked at Apache Commons. Not built in, but reusable. It sounds like StringEscapeUtils has what you want.

[edited to fix typo]


[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
Scott Selikoff
author
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3716
    
    5

Thanks! I'll give it a shot and see.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Escape all special characters in HTML