javascript access denied between jsp applications

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • PromoteDirect@gmail.com

    javascript access denied between jsp applications

    Newsgroups: comp.lang.javas cript
    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.d ocument.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.d ocument.forms[0][fieldname] = x
    gives a javascript error which says 'access is denied'

    Any help would be greatly appreciated

  • Jonas Raoni

    #2
    Re: javascript access denied between jsp applications

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

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


    --
    Now with alcohol <URL:http://youtube.com/watch?v=lnQTZxq xc10> =X
    Jonas Raoni Soares Silva

    Comment

    • PromoteDirect@gmail.com

      #3
      Re: javascript access denied between jsp applications

      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?

      Comment

      • Thomas 'PointedEars' Lahn

        #4
        Re: javascript access denied between jsp applications

        PromoteDirect@g mail.com wrote:
        [color=blue]
        > Newsgroups: comp.lang.javas cript
        > Subject: access denied when trying to pass data between jsps
        > Date: Thu, 09 Mar 2006 10:42:01 -0800[/color]

        Do not reproduce headers.
        [color=blue]
        > [...]
        > When I was using http://localhost:portnumber/ap/page.jsp
        > to open http://localhost:portnumber/otherap/page.jsp
        >
        > and using window.opener.d ocument.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.d ocument.forms[0][fieldname] = x
        > gives a javascript error which says 'access is denied'[/color]

        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
        "computerna me" (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.ex ample != localhost.local domain).

        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

        Comment

        Working...