Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Storing HTML tags in Mysql table

 
Danielle James
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have created an html form for updating different text fields in my database but I would like to send simple HTML formating commands in my text fields and store them in my database. How do I go about doing this and retrieving the results.

Right now when I put a <br /> into my database, and I go to my results jsp page I see the text. It doesn't translate into code. Please tell me what I need to do to make this work. Thanks.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you set the content type header?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64824
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or, something along the way is converting the < and > character to HTML entities, perhaps?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bear Bibeault:
Or, something along the way is converting the < and > character to HTML entities, perhaps?


Yes, it's always a good idea to "view the HTML source" from the client side when debugging or trying to understand web programming.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64824
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is fairly common, in fact highly recommended, to escape data emitted to a page in this manner -- especially if the data was entered by a user. It prevents unintended page breakages when a user enters data such as"</table>" (just think of what that would do to the formatting of your page), or even malicious exploits.

So it is possible that this escaping is a deliberate act.

Most systems that allow "fomratting markup" do not do so with HTML tags. Look at this very site -- formatting is performed via "UBB tags" which use the square bracket characters rather than HTML markup.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic