File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

  html code in PostgreSQL table

 
Jim Borland
Ranch Hand
Posts: 34
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note: My question is about the special HTML character for a non-breaking space. When I type its code into the text composition window it looks fine, but when I "preview" the question, all that is seen is one blank space. Thus, I shall refer to this character as &+nbsp; to keep it from disappearing when I post.

Question: I need to insert a non-breaking space into an html table cell for it to display correctly (if the cell is left empty, there are no borders around it). Things work fine if the final html code for the cell looks like this: <td>&+nbsp;</td>

I'm using Tomcat and JSP pages to generate the HTML code with data for the cells taken from a PostgreSQL database table. The PostgreSQL data is inserted into a Java bean and utilized in the JSP page with JSTL tag:
If I store '&+nbsp' as text in the PostgreSQL table's column, it gets printed as literal text in the html table instead of being recognized as an html code. The final HTML source code looks like this: <td>&+amp;nbsp;</td> (without the "+" sign).

Somehow the "&" character is being converted to the special graphic character "&+amp;" which causes the literal printing of "&." How can I override this conversion when the HTML code is generated and have the content of my PostgreSQL field recognized as an html code?

Thank you!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64192
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's the default behavior of <c:out>. Did you check its documentation to see if you could change that behavior?

P.S. To cause the text &nbsp; to appear in the forums, use the HTML entity for the ampersand character.
 
Jim Borland
Ranch Hand
Posts: 34
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Son of a gun! I never would have thought to check the documentation for There it is, a tag attribute called escapeXml which tells the tag whether to escape characters. I set it to false and everything works perfectly! Thank you very much!

P.S. How did you get the text for <cut> to appear in the forums without the smiley face?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64192
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Click the "disable smilies" check box.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic