By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,572 Members | 946 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,572 IT Pros & Developers. It's quick & easy.

javascript access denied between jsp applications

P: n/a
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 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Pr***********@gmail.com 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
Mar 9 '06 #2

P: n/a
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 '06 #3

P: n/a
Pr***********@gmail.com 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
Mar 11 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.