ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 31st, 2002, 08:36 PM
romeovoid romeovoid is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Posts: 14 romeovoid User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
How to get the name of current file (displayed on web page)

Hi,

I would like to somehow get the current filename of a web page. For example, if my file is located at http://www.mysite.com/myfolder/myfile.asp I would like to be able to extract just the "myfile" or "myfile.asp" portion.

I can't find any reference to this in DOM. I does not seem that this, the filename request, is a popular subject as evidenced by my inability to find much info about it on the web.

Any help would be appreciated.

Thanks.

Reply With Quote
  #2  
Old July 31st, 2002, 10:01 PM
mytch mytch is offline
Dev Articles Novice (500 - 999 posts)
 
Join Date: Apr 2002
Location: Sydney, Australia
Posts: 588 mytch User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 17
Just try an interation through the HTTP headers on your page, and you will see a SCRIPT_NAME or something similar appear. This will contain the name of the current script.

Reply With Quote
  #3  
Old July 31st, 2002, 11:45 PM
romeovoid romeovoid is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Posts: 14 romeovoid User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Request.ServerVariables("SERVER_NAME") Request.ServerVariables("DOCUMENT")
Request.ServerVariables("SCRIPT_NAME")

I have tried all of the above ...

SERVER_NAME yields domain, ex., www.mysite.com
DOCUMENT yields nothing (null)
SCRIPT_NAME yields the full path + filename

Per my reading, DOCUMENT variable, should provide the result I seek. But it does not work.

Any ideas.


I have provide an asp file demonstrating the server variables (rename txt to asp)
Attached Files
File Type: txt test_bad.txt (490 Bytes, 741 views)

Reply With Quote
  #4  
Old August 2nd, 2002, 03:52 AM
cde cde is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: UK
Posts: 7 cde User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I've never heard of the document header, infact by running the following it doesn't appear.

Code:
FOR each KEY in Request.ServerVariables
             Response.Write(KEY & " = " & Request.ServerVariables(KEY) & "&lt br / >")

NEXT



Then since you have the server address from SERVER_NAME and the script address from PATH_INFO just concatinate them together.

Last edited by cde : August 2nd, 2002 at 03:59 AM.

Reply With Quote
  #5  
Old August 2nd, 2002, 08:15 AM
slfrudd slfrudd is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Bradford , UK
Posts: 13 slfrudd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thumbs up current filename of web page

I wrote this VBscript for excel to truncate the filenames in a cell.....

You could easily alter it I think.....

Attribute VB_Name = "Module1"
Sub Macro1()
Attribute Macro1.VB_Description = "Macro recorded 09/08/2001 by Scott L Frudd"
Attribute Macro1.VB_ProcData.VB_Invoke_Func = "t\n14"
'
' Macro1 Macro
' Macro recorded 09/08/2001 by Scott L Frudd
'

Dim a As Integer
Dim b As Integer
Dim c As Integer
c = Len(ActiveCell.FormulaR1C1)
For a = c To 1 Step -1
If Mid$(ActiveCell.FormulaR1C1, a, 1) = "\" Then
b = a
Exit For
End If
Next a
ActiveCell.FormulaR1C1 = Right$(ActiveCell.FormulaR1C1, c - b)
End Sub

Reply With Quote
  #6  
Old August 2nd, 2002, 03:13 PM
romeovoid romeovoid is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Posts: 14 romeovoid User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
thanks for all the help

Apparently I was barking up the wrong tree ... woof! There is NO server variable called "DOCUMENT".

So, I'll have to access it programatically using string manipulation.

Thanks again,

R.

Reply With Quote
  #7  
Old August 6th, 2002, 06:23 AM
rajeevrao rajeevrao is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Bangalore
Posts: 30 rajeevrao User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 17
Send a message via ICQ to rajeevrao
Unhappy hmm ..

apparently there is bno easy way to do it ?? anybody ..
me too have da same problemo ..

thankz..
__________________
Rajeev

Reply With Quote
  #8  
Old August 9th, 2002, 08:27 AM
xa-mua xa-mua is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 1 xa-mua User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
hey guys,

just reading throgh this thread.

this little bit of code will do exactly what you want. not sure what troubles you were having before.

<%@ Language="JScript" %>

Response.Write(Request.ServerVariables("SCRIPT_NAME"));

%>

Reply With Quote
  #9  
Old August 12th, 2002, 09:34 AM
aspnewbie aspnewbie is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: The Great White North
Posts: 361 aspnewbie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 50 sec
Reputation Power: 17
Send a message via MSN to aspnewbie
I have Request.ServerVariables("DOCUMENT_NAME") in my textbook as the way to get at the current file name, but I have tried that and it doesn't seem to work for me!

Reply With Quote
  #10  
Old April 23rd, 2004, 10:59 PM
ke1122 ke1122 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 1 ke1122 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
A little late but....

Here is what I've found that seems to work, even if you have a querystring.

<%
Dim strURL
strURL = Request.ServerVariables("SCRIPT_NAME")
strURL = Split(strURL, "/", -1, 1)
For Each arr in strURL
pagename = arr
Next
response.Write(pagename)
%>

This will split the URL into an array using the "/" as a delimiter. It will assign "pagename" the next value in the array and loop back until it has reached the last value in the array. The last value in the array is your page name (such as index.asp), so when it is done with all of your values, "pagename" automatically contains the name of your page, no matter what page you are on or how many subfolders you have.

Reply With Quote
  #11  
Old April 27th, 2004, 06:19 AM
romeovoid romeovoid is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Posts: 14 romeovoid User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Wow, 2 years later, and a reply (above) that just may work.

Thanks.

Reply With Quote
  #12  
Old April 27th, 2004, 07:28 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Posts: 2,056 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 44 m 22 sec
Reputation Power: 0
A more efficient way
Code:
<%
Dim strURL
strURL = Request.ServerVariables("SCRIPT_NAME")
aryURL = Split(strURL, "/", -1, 1)
response.write(ubound(aryURL))
%>
Hopefully though, you have been able to come up with a solution in the last two years.

Reply With Quote
  #13  
Old April 29th, 2004, 06:16 AM
Stevio Stevio is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 1 Stevio User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Stumpy, that code doesn't work. The last line should say:

response.write(aryURL(ubound(aryURL)))

Reply With Quote
  #14  
Old April 29th, 2004, 07:17 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Posts: 2,056 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 44 m 22 sec
Reputation Power: 0
Oops - thanks stevio.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingASP Development > How to get the name of current file (displayed on web page)


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap