Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > help read URL from framed JSP

Reply
Thread Tools

help read URL from framed JSP

 
 
Chumpmeister
Guest
Posts: n/a
 
      05-28-2004
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.
 
Reply With Quote
 
 
 
 
kaeli
Guest
Posts: n/a
 
      05-28-2004
In article <(E-Mail Removed) >,
http://www.velocityreviews.com/forums/(E-Mail Removed) enlightened us with...
> 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
}
%>


--
--
~kaeli~
If it's tourist season, why can't we shoot them?
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

 
Reply With Quote
 
 
 
 
ExGuardianReader
Guest
Posts: n/a
 
      05-29-2004
kaeli wrote:

> In article <(E-Mail Removed) >,
> (E-Mail Removed) enlightened us with...
>
>>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.


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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[JSP] difference between jsp:forward and jsp:include alexjaquet@gmail.com Java 0 06-02-2006 01:21 PM
__doPostBack and Response.direct not working in non-framed pages. =?Utf-8?B?Q2xhcw==?= ASP .Net 0 11-10-2005 01:35 PM
servlet help - redirecting from within a framed servlet ppcguy Java 1 08-08-2005 03:03 PM
Help! Need online framed prints sduraybito@go.com Digital Photography 0 12-09-2004 04:56 AM
Sessions when using Framed web site? =?Utf-8?B?Q2hyaXN0b3BoZXI=?= ASP .Net 1 01-26-2004 12:35 AM



Advertisments