Code Comments
Programming Forum and web based access to our favorite programming groups.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?
Post Follow-up to this messageoliphant <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
Post Follow-up to this messageOn 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.
Post Follow-up to this messageOn 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.
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.