Trimming White Space: A Quick Reference for the Web Guys @ HP · 177 words posted 11/13/2003 07:18 AM
I bought an iPAQ yesterday (woo hoo!). Today when I went to the HP shopping site to track my order, I entered the following string, minus the quotes:
“H3261452 ”
Notice the trailing white space, which occurred because I cut and paste the order number from my confirmation email. HP didn’t recognize the order number!
Memo to HP managers: be sure to quiz the web guys about trim() during the performance review. Here’s a quick demo in JSP:
<%@ page import="java.net.URLEncoder" %>
<% String myMsg = "hello world "; %>
<% String myMsgTrim = myMsg.trim(); %>
<%= URLEncoder.encode(myMsg) %>
<%= URLEncoder.encode(myMsgTrim) %>
which outputs:
hello+world+
hello+world
How much are those guys getting paid anyway?
Updated 03.09.04:
In defense of the guys at HP, this problem appears to be more common than I initially thought. I just purchased a digital camera at Ritz Camera. If you attempt to track your order number with any trailing spaces, the page simply submits to itself and doesn’t give you any feedback whatsoever! Lame, lame, lamentably lame.
* * *

