• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Displaying data Containing HTML TAGS

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We have a DB application that allows users to freely enter data. Our problem is that if a users enters HTML tags as their data and submits it to our DB, we are able to encode the response and store the data in it's original context (a requirement).

Now, here is the problem. When the data is pulled out from the DB and displayed on the .JSP, if the user had submitted HTML tags, our page doesn't display the HTML tags but rather their browser interprets the tag.

We do not want the browser to interpret the tag, just want the actual characters displayed.
so if a user enteres <B> HELLO WORLD</B>
we want the less than and greater than signs to be displayed..not the phrase HELLO WORLD to be displayed in bold.

Any help is appreicated
 
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think the solution is to encode the HTML text before sending it to the browser, e.g. use &lt; and &gt; instead of < and >. You'll need to encode other stuff too such as & with &amp;. I don't know if there's a standard Java API to do this but there must surely be free, open source APIs available.

Jules
 
Let's get him boys! We'll make him read this tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic