keevin
asked on
page referer
Hi
Is there any equivalent of Request.ServerVariables("U RL") in coldfusion i'm trying HTTP_REFERER though it gave me the whole path. I need the page name only
Regards
Is there any equivalent of Request.ServerVariables("U
Regards
It sounds like you're looking for SCRIPT_NAME, but if that's not right either, you can do a <cfdump var="#CGI#" /> and get all the variable information.
ASKER
script_name gives me /foldername/filename.cfm.
I'm looking for the file name only
I'm looking for the file name only
Try ListLast(SCRIPT_NAME,'/')
ASKER
actually the full path is like below which i've obtain using http_referer
http://www.abc.com/foldername/filename.cfm.
l need to get foldername/filename.cfm
http://www.abc.com/foldername/filename.cfm.
l need to get foldername/filename.cfm
SCRIPT_NAME should return foldername/filename.cfm
ASKER
yeah, but i'm using frame in the page
so SCRIPT_NAME return foldername/topframe.cfm
i need to get foldername/mainframe.cfm
so SCRIPT_NAME return foldername/topframe.cfm
i need to get foldername/mainframe.cfm
ASKER
which i can get using http_referer or path_translator
ASKER
i'm trying to use ListSetAt(1,http_referer,' /') but been unsucessfull
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
<cfset variables.referpath = CGI.HTTP_REFERER />
<cfset variables.path = ListLast(variables.referpa th,"/") />
<cfset variables.referpath = Left(variables.referpath,L en(variabl es.referpa th)-Len(va riables.pa th)) />
<cfset variables.path = ListLast(referpath,'/')&"/ "&path />
I will get you all to start using variable scopes correctly and stop overusing #'s in CFSETs ;oD
Another solution to this would be to treat cgi.script_name as a "/" delimited list as mkishline has done and delete the first two list items from cgi.script_name.
<!--- Remove the domain name --->
<cfset variables.refererPath = ListDeleteAt(cgi.script_na me,2,"/")>
<!--- Remove the http:// --->
<cfset variables.refererPath = ListDeleteAt(variables.ref ererPath,1 ,"/")>
From "http://www.abc.com/foldername/filename.cfm" this will give you "foldername/filename.cfm"
If you're wondering why deleting the list element at position 2 removes the domain name when its actually in position 3 in the list, this is because CF ignores empty list elements. The // between http: and www.abc.com consitutes an empty list item and is ignored.
<cfset variables.path = ListLast(variables.referpa
<cfset variables.referpath = Left(variables.referpath,L
<cfset variables.path = ListLast(referpath,'/')&"/
I will get you all to start using variable scopes correctly and stop overusing #'s in CFSETs ;oD
Another solution to this would be to treat cgi.script_name as a "/" delimited list as mkishline has done and delete the first two list items from cgi.script_name.
<!--- Remove the domain name --->
<cfset variables.refererPath = ListDeleteAt(cgi.script_na
<!--- Remove the http:// --->
<cfset variables.refererPath = ListDeleteAt(variables.ref
From "http://www.abc.com/foldername/filename.cfm" this will give you "foldername/filename.cfm"
If you're wondering why deleting the list element at position 2 removes the domain name when its actually in position 3 in the list, this is because CF ignores empty list elements. The // between http: and www.abc.com consitutes an empty list item and is ignored.