Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

using URLConnection!  RSS feed

 
kriti sharma
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
URLConnection requires a URL.can URLConnection be used only over a network? can i not use it to interact between two simple java programs,one program sending a name through URLConnection and the other program returning the name reversed.both the programs being stored in one direcory on my PC.what url should be given while instantiating URL object?
i gave the url as "http://localhost:80/d:jdk1.2.1/myPrograms/request" and
"http://localhost:80/d:jdk1.2.1/myPrograms/response"
classes being request.class and response.class
big lot of runtime errors appeared.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
URLConnection needs a valid URL. You can't simply make up your own URL syntax and ask URLConnection to figure it out! The URLs you supply are both pointed at a Web server on the local machine; the "d:\..." part is something that the Web server would have to be configured to understand. URLConnection knows the client end of various Internet protocols, but there has to be a real server for it to talk to.
The bottom line is that if you're going to talk to an HTTP, HTTPS, FTP, or SMTP server, then using URLConnection is a good idea. Otherwise, it's inappropriate.
 
kriti sharma
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!