URL parsing issue
07/11/2018 12:08
I'm having a problem with URL parsing. If I construct a URLwith a user name and password, where the user name contains an @ I get amalformed 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 hostwith any FTP program or web browser using the same URL. Is this a bug inJava, a feature, or am I doing something wrong?

Source is Usenet: comp.lang.java.help
Sign in to add a comment

Answer score: 5
07/11/2018 12:08 - Thanks for the reply. I'm sure that you're right, as that does work inevery browser that I've tried. But I can't make it work with java 1.5.0.


Source is Usenet: comp.lang.java.help
Sign in to add a comment

Answer score: 5
07/11/2018 12:08 - The @ in the username should be URL encoded. @ is reserved according torfc 1738 and thus has to be encoded for use in the username:

ftp://bob%40usernet.com:passwd@ftp...


Source is Usenet: comp.lang.java.help
Sign in to add a comment

Answer score: 5
07/11/2018 12:08 -
My mistake. I had an error in the line following this. Thanks for yourhelp, that did work.


Source is Usenet: comp.lang.java.help
Sign in to add a comment

eDiscover
Helpforce eDiscover provides technical articles updated each dayHelpforce eDiscover RSS feed contains the latest technical articles in RSS
Click the logo to go back to the main page
Search eDiscover
  
Categories

Click an icon to go to that category

Helpforce eDiscover contains articles about Microsoft Windows Helpforce eDiscover contains articles about Apple products and MacOS Helpforce eDiscover contains articles about Linux and POSIX operating systems Helpforce eDiscover contains articles about Helpforce Helpforce has a large variety of technical information and articles for you to read Helpforce eDiscover contains articles about databases, MYSQL, SQL Server Oracle Helpforce eDiscover contains articles about Java, JVM and the JRE Helpforce eDiscover contains articles about the QNX operating system Helpforce eDiscover contains articles about Oracle Solaris and Open Solaris Helpforce eDiscover contains articles about RISC OS, Acorn and the BBC Micro Helpforce eDiscover contains articles about Amiga and AmigaOS

Type your comment into the box below