aspose file tools*
The moose likes Java in General and the fly likes tags Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "tags" Watch "tags" New topic
Author

tags

vasu maj
Ranch Hand

Joined: Jul 12, 2001
Posts: 395
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


What a wonderful world!
Sanjeev Kaushik
Ranch Hand

Joined: Aug 01, 2002
Posts: 105
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
Sanjeev Kaushik
Ranch Hand

Joined: Aug 01, 2002
Posts: 105
Sorry I got tripped. If you view source of my previous reply, you'll find the answer
Sanjeev Kaushik
Ranch Hand

Joined: Aug 01, 2002
Posts: 105
will it display, what I am trying
'&' then 'l' then 't' then ';'
Make a single word, then it will work.
<
>
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

You have to escape the amersand.
&lt; and &gt; for < and >
Jithesh Kozhipurath
Ranch Hand

Joined: Aug 27, 2003
Posts: 76
Hai,
You can use the ascii charecters for displaying these kinds of symbols or u can use < > etc.


Jithesh K
vasu maj
Ranch Hand

Joined: Jul 12, 2001
Posts: 395
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

Joined: Mar 06, 2001
Posts: 13459

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: tags
 
Similar Threads
Configuring JEE security in tcServer
stupid Microsoft -- IE 6.0 on XP trouble . . .
Urgent !!! Entity bean JDBC connection Problem !!!
Running sample Beehive NetUI Tutorial using Tomcat
using ajax and struts iterate tags