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

tags

 
vasu maj
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have a problem with display of test wrapped between characters "<" and ">" . It gets inserted into teh database correctly buut while displaying after retrieving from databse correctly, we are losing it as they are being treated as HTML tags. For example if the user enters a value like <Process Object> what we see in the resulatant summary page is empty space. Same thing happnes when user tries to filter a list of values - this particular value doesn't appear in the filter.
We have looked at writing a utility method which escaps the special characters but then our applciation is such that there will be thousands of records ( millions sometimes) and it is too expensive for us to make a call to this method for each cell in the Tabular List. Is there an intelligent way to handle this at the database level? Inserting anyway is not an issue. While retrieving the records can the model somehow present these characters to the view in a special way so that they are displayed as is instead of being treated as tags?

Thanks,
Vasu
 
Sanjeev Kaushik
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use entities for these tags
for "<" it is "<"
">" it is ">"
You can take care of this in two ways. Check for these characters when inserting/updating the database and replace with entities.
If you DB has already grown up, then checking for these characters and replacing with html entities is the only option.
 
Sanjeev Kaushik
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry I got tripped. If you view source of my previous reply, you'll find the answer
 
Sanjeev Kaushik
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
will it display, what I am trying
'&' then 'l' then 't' then ';'
Make a single word, then it will work.
<
>
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to escape the amersand.
&lt; and &gt; for < and >
 
Jithesh Kozhipurath
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai,
You can use the ascii charecters for displaying these kinds of symbols or u can use < > etc.
 
vasu maj
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know about "& lt" and "& gt" but how can I store them in database? I can't store < as "& lt" as it creates problems for me as char length is different. And if I want to replace the tags < and > with & lt and & gt, I need to check the value of each cell and replace whenever I come across them which I do not want to do it is a performance bottleneck as I have told in my posting.
Is there any other way to do it?

Thanks,
Vasu
[ September 22, 2003: Message edited by: vasu maj ]
[ September 22, 2003: Message edited by: vasu maj ]
[ September 22, 2003: Message edited by: vasu maj ]
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe you're heading in the wrong direction. You should store the text as-is in the database - no encoding.
Your problem is in the display of the String. Before you display the string, parse, encode, and display it. When you start pushing display specific ideas like HTML encoding into the database, it means nothing else can read this data from the database without manually doing the HTML decoding. You're making the database HTML specific.
Before you decide whether to parse every time a string is displayed or have some sort of caching mechanism will depend on how often a particular string is used. Personally I'd parse it every time and only implement a more complicated solution if it was warrented.
Dave
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic