aspose file tools*
The moose likes JSP and the fly likes Storing HTML tags in Mysql table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Storing HTML tags in Mysql table" Watch "Storing HTML tags in Mysql table" New topic
Author

Storing HTML tags in Mysql table

Danielle James
Greenhorn

Joined: Apr 08, 2005
Posts: 1
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

Joined: Dec 11, 2004
Posts: 13410

Did you set the content type header?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61209
    
  66

Or, something along the way is converting the < and > character to HTML entities, perhaps?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

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

Joined: Jan 10, 2002
Posts: 61209
    
  66

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Storing HTML tags in Mysql table