page referer

Is there any equivalent of Request.ServerVariables("URL") in coldfusion i'm trying HTTP_REFERER though it gave me the whole path. I need the page name only

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.
keevinAuthor Commented:
script_name gives me /foldername/filename.cfm.

I'm looking for the file name only
Try ListLast(SCRIPT_NAME,'/')
Newly released Acronis True Image 2019

In announcing the release of the 15th Anniversary Edition of Acronis True Image 2019, the company revealed that its artificial intelligence-based anti-ransomware technology – stopped more than 200,000 ransomware attacks on 150,000 customers last year.

keevinAuthor Commented:
actually the full path is like below which i've obtain using http_referer

l need to get foldername/filename.cfm

SCRIPT_NAME should return foldername/filename.cfm
keevinAuthor Commented:
yeah, but i'm using frame in the page

so SCRIPT_NAME return foldername/topframe.cfm

i need to get foldername/mainframe.cfm
keevinAuthor Commented:
which i can get using http_referer or path_translator
keevinAuthor Commented:
i'm trying to use  ListSetAt(1,http_referer,'/') but been unsucessfull
<cfset referpath = HTTP_REFERER />
<cfset path = ListLast(referpath,"/") />
<cfset referpath = Left(referpath,Len(referpath)-Len(path)) />
<cfset path = "#ListLast(referpath,'/')#/#path#" />

Then you can use the #path# variable

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
<cfset variables.referpath = CGI.HTTP_REFERER />
<cfset variables.path = ListLast(variables.referpath,"/") />
<cfset variables.referpath = Left(variables.referpath,Len(variables.referpath)-Len(variables.path)) />
<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_name,2,"/")>
<!--- Remove the http:// --->
<cfset variables.refererPath = ListDeleteAt(variables.refererPath,1,"/")>

From "" 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 consitutes an empty list item and is ignored.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.