Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » JSP Interest »

Re: encoding a URL

Eric Noriega

2003-07-07

Replies:

  The standard allows for space to be encoded as either %20 (the hex
value) or '+'. The server on the other side will decode the URL properly.

Tim Davidson wrote:

>Hi
>
> I have a java class which calls a JSP page using the URLConnection class,
>I construct the URL e.g.
>
>new URL("http://localhost:8080/mywebapp.index.jsp?name=fred smith");
>
>I want to encode the string as a URL, i.e.
>
> "http://localhost:8080/mywebapp.index.jsp?name=fred%20smith"
>
>how can I do this?
>
>URLEncoder doesnt seem to work as it puts '+' where the spaces should be,
>and the URL class doesnt do it for you either.
>
>many thanks in advance.
>
>
>

===========================================================================
To unsubscribe: mailto listserv@(protected)".
For digest: mailto listserv@(protected)".

Some relevant archives, FAQs and Forums on JSPs can be found at:

http://java.sun.com/products/jsp
http://archives.java.sun.com/jsp-interest.html
http://forums.java.sun.com
http://www.jspinsider.com


©2008 junlu.com - Jax Systems, LLC, U.S.A.