*
The moose likes JSP and the fly likes   html code in PostgreSQL table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "  html code in PostgreSQL table" Watch "  html code in PostgreSQL table" New topic
Author

  html code in PostgreSQL table

Jim Borland
Greenhorn

Joined: Oct 26, 2009
Posts: 16
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

Joined: Jan 10, 2002
Posts: 61095
    
  66

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Jim Borland
Greenhorn

Joined: Oct 26, 2009
Posts: 16
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

Joined: Jan 10, 2002
Posts: 61095
    
  66

Click the "disable smilies" check box.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: &nbsp; html code in PostgreSQL table