On Wed, 16 Jun 1999, John Burns wrote:

> Now, I've gotten myself completely confused, and I offer profuse
> apologies to the group for inflicting you with my observations,
> but...
>
> When I use URLEncoder.encode for a URL or just the parameter portion
> of it, there seems to be a problem.  The URL looks like:
>
>     http://host:8080/servlet/MyServlet?param=first name
>
> before encoding, and
>
>    http://host:8080/servlet/MyServlet?param%3Dfirst+name
>
> after encoding everything after the question mark. Which is as
> expected. But getParameter doesn't seem to identify 'param' as a
> parameter name. If I encode the URL like this:
>
>   http://host:8080/servlet/MyServlet?param=first+name
>
> then all is well. Why doesn't it like the hex rep of the equals
> character?  What am I doing wrong? I am using JSDK 2.1 and
> servletRunner under IIS/NT.

I don't think you're doing anything wrong -- the latter encoded url is
the one you want to use -- that is, you don't want to encode the '='s
that separate the name and value for each parameter pair.  You should
only encode the parameter values, not the entire query string or URL
when creating the URL.  The servlet engine has to read/parse the query
string and decode it to create the parameter name/value pairs -- but
it only decodes the values after it has separated the name and value.
So it needs to find the '='s in the encoded URL.  Think about it.  You
wouldn't be able to get an '=' in one of the parameter values if it
worked differently.

Milt Epstein
Research Programmer
Software/Systems Development Group
Computing and Communications Services Office (CCSO)
University of Illinois at Urbana-Champaign (UIUC)
[EMAIL PROTECTED]

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to