Forums Register Login

Trim Trailing Spaces from Field

+Pie Number of slices to send: Send
I'm reading a database to get a Customer Name Char 40, Even though the Customer Name is 16 long , When I read it from the Database its 40 long. So I use the Code below to trim the traling spaces, I then Send it to an input Text box in my JSP which is a UPDATE form. If I then try to update this field , it wont let me unless I hit EOF first. Is there a way to fix this ? What am I missing ? Thanks

+Pie Number of slices to send: Send
Why aren't you:
  • using a VARACHAR DB type so that you dont have to wirry about trailing spaces to begin with?
  • or, using the builtin String trim method rather than inventing the wheel?
  • or, using the JSTL trim function rather than inventing the wheel?


  • I have no idea what you mean by "hitting EOF".
    +Pie Number of slices to send: Send
    I will use the String Trim Function. I'm over 50 , I'm a Mainframe guy. So maybe EOF is a hold over but to be more clear on what I meant. If I do the keyboard combination of EOF ( end of file) which removes the invisible characters after the 1st 16 characters. Once I do the EOF I can key past the 16 characters etc. Also I work for a big shop, and were going against an existing os/390 DB2 database so changing a columns definition isn't that easy in my situation, Since there are a lot of backend programs that would need to be changed. Thanks for the help
    +Pie Number of slices to send: Send
    Ah yes, dealing with legacy databases. Always a joy!

    In any case, if you want to trim in the Java code, using the String class' trim() method is the way to go. Trimming in the JSP itself should use the JSTL's trim() EL function.

    P.S. Over 50 here too.
    I don't get it. A whale wearing overalls? How does that even work? It's like a tiny ad wearing overalls.
    a bit of art, as a gift, that will fit in a stocking
    https://gardener-gift.com


    reply
    reply
    This thread has been viewed 2054 times.
    Similar Threads
    trim function in Javascript
    removing a sequence from ANY string
    Parsing
    NX: Random Access File, byte buffer
    URLyBird: Reading the db-File
    More...

    All times above are in ranch (not your local) time.
    The current ranch time is
    Mar 29, 2024 10:01:31.