Ajax call in Javascript to request on same server but different port

J

Jimmy

Assuming there're 2 different instances of Tomcat.

e.g.
Tomcat #1 runs on http://localhost:10001/webapp1
Tomcat #2 runs on http://localhost:10002/webapp2

If there's Javascript in JSP which runs in webpp1 contains the
following ...
AjaxAnywhere.getAJAX("http://localhost:10002/webapp2",
"zoneInJsp1Webapp1");

Is there a way to make this work? Or if there's a better to do
it? ... preferably to do it right in Javascript (in JSP of webapp1 in
Tomcat #1) ... knowing there's a security concern here but in theory,
they are still using the same domain but just different port.

Thanks,
Jimmy
 
T

Thomas 'PointedEars' Lahn

Jimmy said:
Assuming there're 2 different instances of Tomcat.

e.g.
Tomcat #1 runs on http://localhost:10001/webapp1
Tomcat #2 runs on http://localhost:10002/webapp2

If there's Javascript in JSP which runs in webpp1 contains the
following ...
AjaxAnywhere.getAJAX("http://localhost:10002/webapp2",
"zoneInJsp1Webapp1");

Is there a way to make this work?

Use

AjaxAnywhere.getAJAX("http://localhost:10001/webapp2",
"zoneInJsp1Webapp1");

and http://tuckey.org/urlrewrite/


PointedEars
 
J

Jimmy

Instead of ...
AjaxAnywhere.getAJAX("http://localhost:10001/webapp2",
"zoneInJsp1Webapp1");

It should be ...
AjaxAnywhere.getAJAX("http://localhost:10002/webapp2",
"zoneInJsp1Webapp1"); // didn't actually send request to webapp2

webapp2 is running in different instance of Tomcat (different port on
localhost) than webapp1.

How come different port on the same domain doesn't work?

Thanks,
Jimmy
 
T

Thomas 'PointedEars' Lahn

Jimmy said:
Instead of ...
AjaxAnywhere.getAJAX("http://localhost:10001/webapp2",
"zoneInJsp1Webapp1");

It should be ...
AjaxAnywhere.getAJAX("http://localhost:10002/webapp2",
"zoneInJsp1Webapp1"); // didn't actually send request to webapp2

No, it should not. I wrote what I wrote on purpose.
webapp2 is running in different instance of Tomcat (different port on
localhost) than webapp1.

Which is what matters. However, URL rewrite allows you to access a resource
with another port (or protocol, host name, or path) than the retrieved
resource is usually available at.
How come different port on the same domain doesn't work?

It is all the same problem. The Same Origin Policy imposes that protocol,
second-level domain (and, it appears, with XHR even the host name as
document.domain has no meaning for that), and port number of the request URI
be the same to grant access from one resource to another. I (and others)
have explained that (to you) numerous times before. RTFFAQ.[1]

As I have explained and made a polite request to you repeatedly that you
quote the relevant parts of what you are replying to, as I (and others) have
demonstrated to you numerous times now. I will not ask you again.


PointedEars
___________
[1] http://jibbering.com/faq/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top