Link to home
Start Free TrialLog in
Avatar of cukcuk
cukcuk

asked on

Request.ServerVariables error

hi, how to get the page name from the url using Request.ServerVariables?

E.G.:
http://localhost/test/hihi.asp

I want to get the hihi.asp page name.
Is it possible to do that?
Using PATH_INFO & URL doesn't help.
Please advice.
Avatar of AmericanDogma
AmericanDogma
Flag of United States of America image

Here is a list of the entire servervariables collection:
http://www.4guysfromrolla.com/demos/servervariables.asp

There is nothign to get jsut the name of the actual pag ebut you could do somehtign like Replace(Request.ServerVariables("SCRIPT_NAME"),"/test/","")

That will remove the /test/

Another option would be to trim everythign before the last /    if this suits you needs better let me know and I will write up the code for you using InStr() and Left()
Avatar of cukcuk
cukcuk

ASKER

Hi, AmericanDogma,
Can you show me the trim codings?
I have no idea on how to start.
Thanks.
ASKER CERTIFIED SOLUTION
Avatar of sybe
sybe

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi, try this:

<%

scriptname = request.servervariables("SCRIPT_NAME")

For i = 1 to len(scriptname)
    If mid(scriptname,i,1) = "/" Then
          count = count + 1
    End If
Next

For i = 1 to len(scriptname)
    If mid(scriptname,i,1) = "/" Then
          count2 = count2 + 1
          If count2 = count Then
               Response.Write mid(scriptname,i+1,len(scriptname))
          End If
    End If
Next

%>

Regards,
Wakie.
Avatar of cukcuk

ASKER

Hi, AmericanDogma,
Can you show me the trim codings?
I have no idea on how to start.
Thanks.
Avatar of cukcuk

ASKER

i'll take a look at it...
to get current page name:

<%
ThePageURL=GetURL()
%>
<script language="JavaScript">
<!--
function GetURL()
{
  return location.href
}
//-->
</script>

Enjoy!

MaxOvrdrv2
oops... typo...

this:

return location.href

should read:

return location.href;

forgot the semi-colon at the end...

MaxOvrdrv2
and if that doesnt work... try changing this line:

return location.href;

to one of these 2:

return window.location.href;
OR
return this.location.href;

MaxOvrdrv2


sorry with the email system down yesterday I never made it back to this question