Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

URL parsing issue
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?

Report this thread to moderator Post Follow-up to this message
Old Post
oliphant
10-27-04 08:58 AM


Re: URL parsing issue
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


Report this thread to moderator Post Follow-up to this message
Old Post
Daniel Tryba
10-27-04 08:58 AM


Re: URL parsing issue
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.

Report this thread to moderator Post Follow-up to this message
Old Post
oliphant
10-27-04 08:58 AM


Re: URL parsing issue
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.

Report this thread to moderator Post Follow-up to this message
Old Post
oliphant
10-27-04 08:58 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Java Help archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:45 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.