#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2002
    Location
    Phoenix AZ
    Posts
    30
    Rep Power
    19

    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
    Programmer at large
  2. #2
  3. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Location
    India
    Posts
    7
    Rep Power
    0
    there is a class called URLEncode to care of all these encoding...
    try using it...



    --aabha
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2002
    Posts
    2
    Rep 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.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2002
    Location
    Phoenix AZ
    Posts
    30
    Rep Power
    19

    Unhappy


    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
    Programmer at large
  8. #5
  9. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2002
    Location
    NJ, USA
    Posts
    91
    Rep Power
    13
    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.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2002
    Location
    Phoenix AZ
    Posts
    30
    Rep Power
    19
    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.
    Programmer at large
  12. #7
  13. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2002
    Location
    NJ, USA
    Posts
    91
    Rep Power
    13
    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?
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2002
    Location
    Boston, MA
    Posts
    30
    Rep Power
    57
    Code:
    java.net.URLEncoder.encode(String s)
    
    java.net.URLDecoder.decode(String s)
    Download this :http://java.sun.com/j2se/1.3/docs/api/index.html
  16. #9
  17. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2002
    Posts
    2
    Rep Power
    0
    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
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2002
    Location
    Phoenix AZ
    Posts
    30
    Rep Power
    19
    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.
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2002
    Location
    Boston, MA
    Posts
    30
    Rep Power
    57

    Question


    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.
  22. #12
  23. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2002
    Location
    Phoenix AZ
    Posts
    30
    Rep Power
    19
    Thanks. We'll do that. I appreciate everyone's help very much.

IMN logo majestic logo threadwatch logo seochat tools logo