javascript access denied between jsp applications

Discussion in 'Javascript' started by PromoteDirect@gmail.com, Mar 9, 2006.

  1. Guest

    Newsgroups: comp.lang.javascript
    Subject: access denied when trying to pass data between jsps
    Date: Thu, 09 Mar 2006 10:42:01 -0800

    I have two jsp applications. One written with struts and one without.
    My struts based application uses window.open to open the first page of
    my non-struts application, the user goes through a number of screens
    and I then need to copy info from my non struts ap to fields of a form
    on my struts ap.

    When I was using http://localhost:portnumber/ap/page.jsp
    to open http://localhost:portnumber/otherap/page.jsp

    and using window.opener.document.forms[0][fieldname] = x
    I had no problems.

    However when I try to access it from another machine with:
    http://computername:portnumber/ap/page.jsp
    The page opens but the window.opener.document.forms[0][fieldname] = x
    gives a javascript error which says 'access is denied'

    Any help would be greatly appreciated
    , Mar 9, 2006
    #1
    1. Advertising

  2. Jonas Raoni Guest

    wrote:
    > However when I try to access it from another machine with:
    > http://computername:portnumber/ap/page.jsp
    > The page opens but the window.opener.document.forms[0][fieldname] = x
    > gives a javascript error which says 'access is denied'


    <URL:http://jibbering.com/faq/#FAQ4_19>


    --
    Now with alcohol <URL:http://youtube.com/watch?v=lnQTZxqxc10> =X
    Jonas Raoni Soares Silva
    http://www.jsfromhell.com
    Jonas Raoni, Mar 9, 2006
    #2
    1. Advertising

  3. Guest

    Thanks for that,

    Both of my aps run on the same computer - and they are both running on
    the same web server. Is there a way I can set the document.domain
    attribute to allow the interaction between my pages?
    , Mar 9, 2006
    #3
  4. wrote:

    > Newsgroups: comp.lang.javascript
    > Subject: access denied when trying to pass data between jsps
    > Date: Thu, 09 Mar 2006 10:42:01 -0800


    Do not reproduce headers.

    > [...]
    > When I was using http://localhost:portnumber/ap/page.jsp
    > to open http://localhost:portnumber/otherap/page.jsp
    >
    > and using window.opener.document.forms[0][fieldname] = x
    > I had no problems.
    >
    > However when I try to access it from another machine with:
    > http://computername:portnumber/ap/page.jsp
    > The page opens but the window.opener.document.forms[0][fieldname] = x
    > gives a javascript error which says 'access is denied'


    Because what happens is that http://computername:portnumber/ap/page.jsp
    tries to access http://localhost:portnumber/otherap/page.jsp which is not
    allowed as the domains are different (computername != localhost). If you
    search the archives for "Same Origin Policy", you will see that not even
    document.domain helps you here, as either you do not provide a FQDN for
    "computername" (you should always post real addresses if you can), hence
    there is no explicit second-level domain, or the second-level domains are
    different (your.domain.example != localhost.localdomain).

    If you use relative URIs instead, there should not be any problem.
    Because, for example, /otherap/page.jsp refers to
    http://computername:portnumber/otherap/page.jsp if accessed from
    http://computername:portnumber/ap/page.jsp. See RFC3986.


    HTH

    PointedEars
    Thomas 'PointedEars' Lahn, Mar 11, 2006
    #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. Sean Aitken
    Replies:
    3
    Views:
    10,948
    Alex Hunsley
    Oct 21, 2004
  2. Replies:
    2
    Views:
    3,245
  3. Replies:
    0
    Views:
    4,325
  4. praba kar
    Replies:
    2
    Views:
    839
    Paul Rubin
    May 4, 2005
  5. admyc
    Replies:
    2
    Views:
    228
    Thomas 'PointedEars' Lahn
    Sep 4, 2007
Loading...

Share This Page