?
Solved

Request.ServerVariables error

Posted on 2003-02-18
10
Medium Priority
?
230 Views
Last Modified: 2008-03-06
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.
0
Comment
Question by:cukcuk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +2
10 Comments
 
LVL 3

Expert Comment

by:AmericanDogma
ID: 7979848
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()
0
 

Author Comment

by:cukcuk
ID: 7979929
Hi, AmericanDogma,
Can you show me the trim codings?
I have no idea on how to start.
Thanks.
0
 
LVL 28

Accepted Solution

by:
sybe earned 200 total points
ID: 7979970
I recently answered a similar question:
http://www.experts-exchange.com/Web/Web_Languages/ASP/Q_20510613.html



Function GetPageName()
   Dim aPathInfo
   aPathInfo = Split(Request.Servervariables("PATH_INFO"),"/")
   GetPageName = aPathInfo(Ubound(aPathInfo))
End Function
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:Wakie
ID: 7980055
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.
0
 

Author Comment

by:cukcuk
ID: 7980137
Hi, AmericanDogma,
Can you show me the trim codings?
I have no idea on how to start.
Thanks.
0
 

Author Comment

by:cukcuk
ID: 7980140
i'll take a look at it...
0
 
LVL 10

Expert Comment

by:MaxOvrdrv2
ID: 7982303
to get current page name:

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

Enjoy!

MaxOvrdrv2
0
 
LVL 10

Expert Comment

by:MaxOvrdrv2
ID: 7982311
oops... typo...

this:

return location.href

should read:

return location.href;

forgot the semi-colon at the end...

MaxOvrdrv2
0
 
LVL 10

Expert Comment

by:MaxOvrdrv2
ID: 7982339
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


0
 
LVL 3

Expert Comment

by:AmericanDogma
ID: 7989065
sorry with the email system down yesterday I never made it back to this question
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question