?
Solved

Request.ServerVariables error

Posted on 2003-02-18
10
Medium Priority
?
237 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
  • 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Is your organization moving toward a cloud and mobile-first environment? In this transition, your IT department will encounter many challenges, such as navigating how to: Deploy new applications and services to a growing team Accommodate employee…
Suggested Courses
Course of the Month8 days, 11 hours left to enroll

621 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