This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Http Get external url socket Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Http Get external url socket" Watch "Http Get external url socket" New topic
Author

Http Get external url socket

Jose Maestre
Greenhorn

Joined: Oct 06, 2012
Posts: 2
Hello,

I have to make a function that have to make a get into a public url, it will return me a plain text wich.

Depending on that i will make a validation.

I try to make it with the dojo ajax get method but since is a different domain it will not work ( only on Explorer).

How I can make that call to the external domain and manage the answer.

the url will be something like this.

htt://my.socket:8080/?option1=1&option2=2.

It can be with ajax or just a java class.
Panagiotis Kalogeropoulos
Rancher

Joined: May 27, 2011
Posts: 99

Have you tried using the java.net api? Particularly, the URL and URLConnection classes?
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Panagiotis Kalogeropoulos wrote:Have you tried using the java.net api? Particularly, the URL and URLConnection classes?
And this answer has nothing to do with JavaScript.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Jose Maestre wrote:
I have to make a function that have to make a get into a public url, it will return me a plain text wich.


Can you change the output to JSONP, than it will be easy to make it work in any browser.

Modern day browser support CORS which will let you make cross domain calls. If you have to support older browsers, you need to use a proxy on the same domain or the JSONP call I suggested above.

Eric
Panagiotis Kalogeropoulos
Rancher

Joined: May 27, 2011
Posts: 99

And this answer has nothing to do with JavaScript.


Very true. I did not pay attention to the keyword "dojo" and thought that it referred to core java. Apologies to the topic starter if I mislead him with my answer.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Http Get external url socket