Home > Archive > Java Help > October 2004 > URL parsing issue
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| oliphant 2004-10-27, 3:58 am |
| I'm having a problem with URL parsing. If I construct a URL
with a user name and password, where the user name contains an @ I get a
malformed URL exception. For example, if my parameters are:
user name = bob@usernet.com
password = password
host = ftp.test.com
and I try to construct a URL:
URL connection = new URL("ftp://bob@usernet.com:password@ftp.test.com");
I get a malformed URL exception. Even though I can connect to the host
with any FTP program or web browser using the same URL. Is this a bug in
Java, a feature, or am I doing something wrong?
| |
| Daniel Tryba 2004-10-27, 3:58 am |
| oliphant <oliphant@ophidian.net> wrote:
> and I try to construct a URL:
>
> URL connection = new URL("ftp://bob@usernet.com:password@ftp.test.com");
>
> I get a malformed URL exception. Even though I can connect to the host
> with any FTP program or web browser using the same URL. Is this a bug in
> Java, a feature, or am I doing something wrong?
The @ in the username should be URL encoded. @ is reserved according to
rfc 1738 and thus has to be encoded for use in the username:
"ftp://bob%40usernet.com:passwd@ftp..."
--
Daniel Tryba
| |
| oliphant 2004-10-27, 3:58 am |
| On Wed, 27 Oct 2004 02:42:01 +0000, Daniel Tryba wrote:
> oliphant <oliphant@ophidian.net> wrote:
>
> The @ in the username should be URL encoded. @ is reserved according to
> rfc 1738 and thus has to be encoded for use in the username:
>
> "ftp://bob%40usernet.com:passwd@ftp..."
Thanks for the reply. I'm sure that you're right, as that does work in
every browser that I've tried. But I can't make it work with java 1.5.0.
| |
| oliphant 2004-10-27, 3:58 am |
| On Wed, 27 Oct 2004 03:15:47 +0000, oliphant wrote:
> On Wed, 27 Oct 2004 02:42:01 +0000, Daniel Tryba wrote:
>
>
> Thanks for the reply. I'm sure that you're right, as that does work in
> every browser that I've tried. But I can't make it work with java 1.5.0.
My mistake. I had an error in the line following this. Thanks for your
help, that did work.
|
|
|
|
|