This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes JSP and the fly likes Get URL of parent page in an included JSP page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSP
Bookmark "Get URL of parent page in an included JSP page" Watch "Get URL of parent page in an included JSP page" New topic
Author

Get URL of parent page in an included JSP page

rishi athalye
Greenhorn

Joined: Aug 20, 2002
Posts: 2
We have a shtml page. Within this page, we have included a JSP page.
How do i get the URL of the parent/shtml page from within this JSP page ?
I tried getRequestURI etc, but i just get the URL of the JSP page. Referrer will also not work as that is some other page.
Thanks.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61318
    
  66

Because the server-side include is being handled completely outside of the JSP/Servlet arena, there isn't likely to be a way to obtain this information unless your web server somehow makes it available as a system parameter or something. What web server is handling the ssi?
If the web server does not make this info available, then a somewhat hacky way to do this (if it is absolutely essentiall information -- I'd examine my design to see why I needed this info before resorting to hacks) is to pass the info on the request to the JSP page (assuming your ssi engine allows that).
Not much help,
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
rishi athalye
Greenhorn

Joined: Aug 20, 2002
Posts: 2
Thanks. We are using JRun.
I tried even passing it as a query string to the original page, but as you said, it's outside the scope of the JSP request and thus the request object does not catch the parameters.
Also, I can't pass any query string with the include directive like that --
include virtual="xyz.jsp?fname=abc"
Is there any way i can pass any parameter to the JSP page from an html/shtml page.
I am now going to look into setting custom headers and try to get it through getHeaderNames.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61318
    
  66

Before resorting to fragile hackery, examine why it is that you need to know where you came from within the JSP page. Backing off from the problem might reveal a better design with a cleaner solution.
hth,
bear
 
GeeCON Prague 2014
 
subject: Get URL of parent page in an included JSP page