473,395 Members | 1,905 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to get referrer of parent page?

I have a main page say Main.jsp which has a Iframe in it whose src is page1.jsp

Page1.jsp has a form in it and we have a button on Main.jsp

We submit form inside Ifame(page1.jsp) using the button on main page with javascript.

Once a form is submitted, we redirect it to some error page in case of error.
Here we have a back button which should move us to Main.jsp.

We are using referer for identifying the page from which error page is coming so that when we press back button, we will be redirect to correct page.

But, whats happening is that when we are submitting form, url of Frame is passed as referer instead of Main.jsp.

How can we get the Main.jsp in Referer?

Please note for some security reason history.go(-1) doesn't work.
Dec 1 '09 #1
6 11861
hsriat
1,654 Expert 1GB
In the jsp code of page1.jsp, see if the referrer (HTTP_REFERRER) is anyone other than Main.jsp, redirect it to Main.jsp.
Dec 1 '09 #2
Thanks hsriat for your reply. How can I redirect HTTP_REFERRER to Main.jsp
I used setHeader to set the Referer to Main.jsp, but IE again sets it to page1.jsp
Dec 2 '09 #3
hsriat
1,654 Expert 1GB
You don't need to do anything to referrer, just find out who is the referrer to page1.jsp
If the referrer is main.jsp, no need to do anything, but if the referrer is not main.jsp, redirect the client to the Main.jsp page.

Follow this psudocode..

if (getHeader("HTTP_REFERRER") != Main.jsp)
setHeader("Location: Main.jsp")

This above code needs to be in the starting of page1.jsp
I hope I made it clear this time.
Dec 3 '09 #4
Thanks a lot man, it really worked
Dec 3 '09 #5
One more issue with this:(

Previously I hard coded my URL like setHeader("Location", "http://server:host/a/abc/Main.jsp) and it worked all the time.

But, I can't hard code the URL as it contains server/host/directory structure, etc..

How can I get the URL of parent of IFrame and store it permanently to always pass that URL in setHeader ?

I have checked in my Page1.jsp, first time doing getHeader("Referer") returns url for Main.jsp to which I want to redirect. But, when a submit button is clicked in frame, Referer is changed.

say I have done like:
setHeader("Location", getHeader("Referer")) - Just not to hardcode my url, but it doesn't work.

Please let me know is there any way I can save the Referer(URL) which is coming first (Main.jsp) time or I can get the Iframe parent in jsp, so that I can set header with that URL.

I hope you understood the problem
Dec 4 '09 #6
hsriat
1,654 Expert 1GB
I could not understand what exactly the problem is. Try to provide a relative url in the location header rather than absolute.

Eg. Instead of setHeader("Location", "http://www.xxx.yyy/zzz.jsp"), try setHeader("Location", "/zzz.jsp") depending upon what is the present location.

And for comparing the referrer, make use of some algorithm/method to check if its matching, rather than to check if it is exactly equal with object.equals() method.

Not the best solution, but I think it will work.
Dec 7 '09 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: kuok benny | last post by:
Hi, I am trying to use the document.referrer to get the referrer of my home page. Occationally, I get the value of 'blockedReferrer'. Actually how this happen, how the client blocked the...
1
by: brett | last post by:
When I use this code: <select name="status" onChange = "location.href=this.options.value"> <option value="mypage.htm">Select View</option> </select> I don't have a referrer. When I click an...
3
by: Alex | last post by:
Hi!! i have a major problem, and i've been searching for a solution for about 2 weeks, but havent found one. i have to do a POST-Request to a server, but the server shouldnt know my referrer....
2
by: X l e c t r i c | last post by:
Hi, I'm trying to put the last URL visited to a text input using history.previous for WebTV (because I can't get document.referrer to work with WebTV) and document.referrer for PC. This is for...
0
by: Harley | last post by:
I'm having problems getting the referrer URL in a VB.NET ASP.NET page. A simple piece of code like this: if not Request.URLReferrer is nothing then _REFUrl = Request.URLReferrer.Host.ToString...
3
by: NWx | last post by:
Hi, I have a ASP.NET application using forms authentication Default page is default.aspx, and login page is login.aspx As I perform authentication in Login page, I want to update a log table...
1
by: Mike Dee | last post by:
Hi All - I'm having a strange problem I'm wondering if anyone can shed some light on. When I use ASP or ASP.NET code to get the referrer information from the server side, it comes back as null. ...
1
by: Trev | last post by:
Hi everyone, I'm trying to modify an existing piece of Javascript that will enable a redirect to a page based on IP address and/or keywords in the referrer; for instance, redirecting an existing...
10
by: Trev | last post by:
Hi all, I'm trying to create some javascript that will provide the user of the referring page, but if I do something like the following: <HTML> <HEAD> </HEAD> <BODY> <script>
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.