help read URL from framed JSP

Discussion in 'Java' started by Chumpmeister, May 28, 2004.

  1. Chumpmeister

    Chumpmeister Guest

    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.
     
    Chumpmeister, May 28, 2004
    #1
    1. Advertising

  2. Chumpmeister

    kaeli Guest

    In article <>,
    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
     
    kaeli, May 28, 2004
    #2
    1. Advertising

  3. kaeli wrote:

    > In article <>,
    > 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
     
    ExGuardianReader, May 29, 2004
    #3
    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. =?Utf-8?B?Q2hyaXN0b3BoZXI=?=

    Sessions when using Framed web site?

    =?Utf-8?B?Q2hyaXN0b3BoZXI=?=, Jan 25, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    356
    Steve C. Orr [MVP, MCSD]
    Jan 26, 2004
  2. =?Utf-8?B?Q2xhcw==?=
    Replies:
    0
    Views:
    1,513
    =?Utf-8?B?Q2xhcw==?=
    Nov 10, 2005
  3. ppcguy
    Replies:
    1
    Views:
    631
    Andrea Desole
    Aug 8, 2005
  4. DiLu790

    Way to Redirect Framed Page???

    DiLu790, Dec 14, 2003, in forum: HTML
    Replies:
    24
    Views:
    1,165
    Hywel Jenkins
    Dec 16, 2003
  5. Paul F. Johnson

    Replacing a framed website with css

    Paul F. Johnson, Sep 24, 2004, in forum: HTML
    Replies:
    8
    Views:
    1,938
    Paul F. Johnson
    Sep 26, 2004
Loading...

Share This Page