help read URL from framed JSP

C

Chumpmeister

I wonder if anyone can tell me if this is possible? I have a JSP that
appears in a frame on another page. Is it possible to read the URL of
the page hosting my 'framed' JSP.

e.g. www.mysite.com has a page mypage.htm
mypage.htm has a frame containing myjsp.jps

Can myjsp.jsp read the parent's URL (www.mysite.com/mypage.htm) ?

I appreciate any advise.
 
K

kaeli

I wonder if anyone can tell me if this is possible? I have a JSP that
appears in a frame on another page. Is it possible to read the URL of
the page hosting my 'framed' JSP.

e.g. www.mysite.com has a page mypage.htm
mypage.htm has a frame containing myjsp.jps

Can myjsp.jsp read the parent's URL (www.mysite.com/mypage.htm) ?

I appreciate any advise.

Not that I know of, since server-side, there is no concept of a frame.
But javascript can.
You can use javascript to check it and post back to the server.

javascript can see it with
window.parent.location

You can post it back with the url and parse it.
Note: must be in body of html document so javascript runs

(following works in theory: untested)

<%
String page = request.getParameter("page");
if (page == null || page.length() == 0)
{
%>
<script type="text/javascript">
if (window.parent.location)
{
var p = window.parent.location;
// reload location with page param
window.location = window.location+ "?page="+p;
}
</script>
<%
}
else
{
// do whatever with page var
}
%>


--
 
E

ExGuardianReader

Check the "Referer" HTTP header. Most browsers send this containing the
URL of the page which made the request.

It is not mandatory, YMMV.

Nige
 

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

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,054
Latest member
LucyCarper

Latest Threads

Top