users@glassfish.java.net

java.net.URLEncoder class question

From: emiddio-frontier <emiddio_at_frontier.com>
Date: Mon, 23 May 2011 19:06:02 -0700

i have a filename "Bello Terry_ Snow#605B.jpg" -- not counting the ' " '
chars;

the name contains a blanks, and and '#' characters.

i want to serve it over http with a servlet.

when i use URLEncoder.encode(filename, "UTF-8") the result is
"Bello+Terry_+Snow%23605B.jpg"

that String is not accepted/decoded properly by the standard default
glassfish v301 servlet --
it refuses to serve up the file. -- yet it contains the ' + ' chars that
i read are to be used
to represent blanks.

when the blanks are converted to %20 -- ie the resultant String is
"Bello%20Terry_%20Snow%23605B.jpg" -- the file is served up.

What is going on here ?; are ' + ' no longer the way to encode spaces ?

What method of which class can i use to generate the proper encoding ?

thanks

gary