The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> Java Help
|
passing unusual text
Discuss passing unusual text in the Java Help forum on Dev Shed. passing unusual text Java Help forum discussing all Java platforms - J2ME, J2SE and J2EE - as well as relevant standards, APIs and frameworks such as Swing, Servlets, JSPs, Applets, Struts, Spring, Hibernate, ANT, EJB, and other Java-related topics.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

May 21st, 2002, 12:49 AM
|
|
Registered User
|
|
Join Date: May 2002
Location: Phoenix AZ
|
|
|
passing unusual text
I'm really new to JSP, but my partner has been working with it for quite awhile. He's encountered a problem that I believe can be addressed easily, but I can't find anything about this in the books, and I'm not quite sure what I need to look for.
We're passing serveral parameters to the next window as part of an sql "where" clause to select data based upon the criteria selected. It works great until we select criteria with certain characters, such as the British currency sign.
The temporary solution is to go through the data and make sure we bypass any fields with these characters, NOT a good solution, but neither of us can figure out a permanent solution, since it's not a good idea to have to sift through the data and figure out the hexadecimal for each and every possible non-alphanumeric character so that it doesn't trash our stuff.
Any ideas or suggestions are most welcome. Thank you so much for you time.
Kind regards,
Pat Flickner
|

May 21st, 2002, 01:38 PM
|
|
Member
|
|
Join Date: Mar 2002
Location: India
Posts: 7
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
there is a class called URLEncode to care of all these encoding...
try using it...
--aabha
|

June 2nd, 2002, 12:53 PM
|
|
Junior Member
|
|
Join Date: Jun 2002
Posts: 2
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
in the first place, such signs should not exist in the database or front end.
But anyway I believe you can look at things like itemID. Try implementing a ID field in yer database as autonumber so that you can set your desc to be anything.
|

June 4th, 2002, 05:04 PM
|
|
Registered User
|
|
Join Date: May 2002
Location: Phoenix AZ
|
|
Thanks for the urlencode, but it turns out it's no good on anything less than MSIE 5.5, and with the pace at which our other markets move, it could be another year before they upgrade, so we're stuck. We did try it, it works, but we had to pull it when we found out that not everyone is even at 5.0 yet.
As for the response about "such signs should not exist," yes, actually, they should be allowed. This is data we're talking about, real, honest-to-goodness data that the clients expect to see. And since we cater to the customer, their wish is our command. But if you could explain what you mean by setting up an ID field, I would love to hear it. Since we can't use the first method, yours sounds like it might be the next best thing.
Thank you both for your replies.
Kind regards,
Pat Flickner
|

June 5th, 2002, 07:13 AM
|
 |
Contributing User
|
|
Join Date: May 2002
Location: NJ, USA
Posts: 91
Time spent in forums: 1 h 1 m 8 sec
Reputation Power: 11
|
|
Quote: Originally posted by pflick
As for the response about "such signs should not exist," yes, actually, they should be allowed. This is data we're talking about, real, honest-to-goodness data that the clients expect to see. And since we cater to the customer, their wish is our command. |
Is this currency appearing within a string of text or is it a stand-alone field? If the field contains a value only then the currency symbol should not be included.
|

June 5th, 2002, 03:17 PM
|
|
Registered User
|
|
Join Date: May 2002
Location: Phoenix AZ
|
|
|
Yes, it is currency, but we have no way of knowing what the data will contain until we get an error. And removing any symbols for java causes the results to not appear because they are data entered by the customer with the symbols. (The first page allows subsetting -- we do not hard-code everything. It's a fully data-driven design which is controlled by the DBA.) So you can see my dilemma.
|

June 5th, 2002, 04:24 PM
|
 |
Contributing User
|
|
Join Date: May 2002
Location: NJ, USA
Posts: 91
Time spent in forums: 1 h 1 m 8 sec
Reputation Power: 11
|
|
Quote: Originally posted by pflick
Yes, it is currency, but we have no way of knowing what the data will contain until we get an error. And removing any symbols for java causes the results to not appear because they are data entered by the customer with the symbols. (The first page allows subsetting -- we do not hard-code everything. It's a fully data-driven design which is controlled by the DBA.) So you can see my dilemma. |
I think the solution may be in using a method of the String class. Could you share your code and let me know where the errors are occurring and with an example of the data that's causing the error?
|

June 11th, 2002, 02:57 PM
|
|
Contributing User
|
|
Join Date: Jun 2002
Location: Boston, MA
|
|
|

June 12th, 2002, 06:46 AM
|
|
Junior Member
|
|
Join Date: Jun 2002
Posts: 2
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
Quote: Originally posted by pflick
Thanks for the urlencode, but it turns out it's no good on anything less than MSIE 5.5, and with the pace at which our other markets move, it could be another year before they upgrade, so we're stuck. We did try it, it works, but we had to pull it when we found out that not everyone is even at 5.0 yet.
As for the response about "such signs should not exist," yes, actually, they should be allowed. This is data we're talking about, real, honest-to-goodness data that the clients expect to see. And since we cater to the customer, their wish is our command. But if you could explain what you mean by setting up an ID field, I would love to hear it. Since we can't use the first method, yours sounds like it might be the next best thing.
Thank you both for your replies.
Kind regards,
Pat Flickner |
Hi,
What do you mean by url encode does not work on anything less than IE 5.0. I thought its a server side thing...but anyway on the ID field.
Use a unique ID to uniquely identify each item in your database row. Let the ID be an autonumber too
|

June 12th, 2002, 11:10 AM
|
|
Registered User
|
|
Join Date: May 2002
Location: Phoenix AZ
|
|
|
URLencode is through javascript, which is client-side. We just (last night) found another item accidentally when we were researching the issue: escape(). (There's a noescape() as well.) The ecapse() function seems to handle the situation quite nicely. We're doing some further tests over the next few days, so I'll let you know.
|

June 12th, 2002, 02:01 PM
|
|
Contributing User
|
|
Join Date: Jun 2002
Location: Boston, MA
|
|
Spreading the logic between java and javascript is not a good idea in this case. I don't see why you would use javascript. Keep it simple. Stick with Java.
You might find it useful to make a utility class. This can help you avoid too much java code in your pages, meaning less maintenance and work.
Start by adding this to your scriptlet:
Code:
java.net.URLDecoder.decode(value);
Then take look at your code, it's objective, and write yourself a utility method.
|

June 12th, 2002, 02:53 PM
|
|
Registered User
|
|
Join Date: May 2002
Location: Phoenix AZ
|
|
|
Thanks. We'll do that. I appreciate everyone's help very much.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|