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

Discussion in 'Javascript' started by Jimmy, Aug 12, 2007.

  1. Jimmy

    Jimmy Guest

    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
     
    Jimmy, Aug 12, 2007
    #1
    1. Advertising

  2. Re: Ajax call in Javascript to request on same server but differentport

    Jimmy wrote:
    > 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
    --
    realism: HTML 4.01 Strict
    evangelism: XHTML 1.0 Strict
    madness: XHTML 1.1 as application/xhtml+xml
    -- Bjoern Hoehrmann
     
    Thomas 'PointedEars' Lahn, Aug 12, 2007
    #2
    1. Advertising

  3. Jimmy

    Jimmy Guest

    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
     
    Jimmy, Aug 13, 2007
    #3
  4. Re: Ajax call in Javascript to request on same server but differentport

    Jimmy wrote:
    > 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/
    --
    Anyone who slaps a 'this page is best viewed with Browser X' label on
    a Web page appears to be yearning for the bad old days, before the Web,
    when you had very little chance of reading a document written on another
    computer, another word processor, or another network. -- Tim Berners-Lee
     
    Thomas 'PointedEars' Lahn, Aug 13, 2007
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alexander N. Spitzer
    Replies:
    21
    Views:
    1,848
    Randolf Richardson
    Aug 16, 2004
  2. Christopher Brewster
    Replies:
    5
    Views:
    374
    John Machin
    Nov 14, 2008
  3. bluebaron
    Replies:
    3
    Views:
    787
    Jonathan N. Little
    Nov 4, 2009
  4. Replies:
    1
    Views:
    674
    Toni Erdmann
    Mar 2, 2005
  5. pradeep
    Replies:
    3
    Views:
    147
    Dr J R Stockton
    Jun 7, 2007
Loading...

Share This Page