473,395 Members | 1,791 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

getting file Name

Hi all,

I'm searching to find the name of the file in which i execute a script.

example : i'm into /directory/page.asp

and i d like to know which variable could help me to find the path of the
file on server side.

thanks a lot and have a nice day
Laurent
http://www.chazallet.com
Jul 19 '05 #1
4 1545
Make a page like this:

<%
For Each q in Request.ServerVariables
Response.Write q & " = " & Request.ServerVariables(q) & "<hr>"
Next
%>

That'll show you all the server variables.

Also see this: http://www.aspfaq.com/show.asp?id=2072

Ray at home

"Laurent" <lg*****@wonderweb.net> wrote in message
news:40***********************@news.skynet.be...
Hi all,

I'm searching to find the name of the file in which i execute a script.

example : i'm into /directory/page.asp

and i d like to know which variable could help me to find the path of the
file on server side.

thanks a lot and have a nice day
Laurent
http://www.chazallet.com

Jul 19 '05 #2
Laurent wrote:

I'm searching to find the name of the file in which i execute a
script.

example : i'm into /directory/page.asp

and i d like to know which variable could help me to find the
path of the file on server side.


Here's one JScript way of doing it:

function showServerVariables() {
var v = Request.ServerVariables
e = new Enumerator(v),
a = new Array(),
s = new String()
for (; !e.atEnd(); e.moveNext()) {
s = String(e.item())
if (!/^ALL/.test(s))
a.push(
"<TD><B>" + s + "</B></TD>" +
"<TD>" + split(v(s)) + "</TD>"
)
}

return "<TABLE><TR VALIGN=\"top\">" +
a.join("</TR>\r\n<TR VALIGN=\"top\">") +
"</TR>\r\n</TABLE>"

function split(item) {
item = String(item)
return item.replace(
/([;\n])/g,"$1<BR>"
).replace(
/(,)/g,"$1 "
).replace(
/(&)/g,"&<BR>&nbsp;&nbsp;&nbsp;"
)
}
}

<%=showServerVariables()%>
--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Jul 19 '05 #3
WOW! And to think it could have been done in only 3 lines instead.

Nice job.

Bob Lehmann
Verbose, overly-complex code will be read at a cost of $500 per line.

"Dave Anderson" <GT**********@spammotel.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
Laurent wrote:

I'm searching to find the name of the file in which i execute a
script.

example : i'm into /directory/page.asp

and i d like to know which variable could help me to find the
path of the file on server side.
Here's one JScript way of doing it:

function showServerVariables() {
var v = Request.ServerVariables
e = new Enumerator(v),
a = new Array(),
s = new String()
for (; !e.atEnd(); e.moveNext()) {
s = String(e.item())
if (!/^ALL/.test(s))
a.push(
"<TD><B>" + s + "</B></TD>" +
"<TD>" + split(v(s)) + "</TD>"
)
}

return "<TABLE><TR VALIGN=\"top\">" +
a.join("</TR>\r\n<TR VALIGN=\"top\">") +
"</TR>\r\n</TABLE>"

function split(item) {
item = String(item)
return item.replace(
/([;\n])/g,"$1<BR>"
).replace(
/(,)/g,"$1 "
).replace(
/(&)/g,"&<BR>&nbsp;&nbsp;&nbsp;"
)
}
}

<%=showServerVariables()%>
--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message.

Use of this email address implies consent to these terms. Please do not contact me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.

Jul 19 '05 #4
Bob Lehmann wrote:
WOW! And to think it could have been done in only 3 lines instead.
Or two:
for (var v=Request.ServerVariables,e=new
Enumerator(v),a=[],s="";!e.atEnd();e.moveNext()){s=String(e.item()); a.push("
["+s+"] "+v(s))}
<%=a.join("<BR>")%>

Why not one?
<%=Request.ServerVariables%>

Of course, neither of these breaks out the cookies and their keyed
name/value pairs into separate line items as my posted example does.

But I suppose you think an example must be written anew each time a question
is to be answered, rather than lifted from any utility scripts we may have
lying around. I confess I am not fond of leaving markup in my examples, but
I considered it relevant in this case.
Nice job.

Bob Lehmann
Verbose, overly-complex code will be read at a cost of $500 per line.


Whatever. If push/join/replace is complex, then sue me.

function showServerVariables() {
var v = Request.ServerVariables,
e = new Enumerator(v),
a = new Array(),
s = new String()
for (; !e.atEnd(); e.moveNext()) {
s = String(e.item())
if (!/^ALL/.test(s))
a.push(
"<TD><B>" + s + "</B></TD>" +
"<TD>" + split(v(s)) + "</TD>"
)
}

return "<TABLE><TR VALIGN=\"top\">" +
a.join("</TR>\r\n<TR VALIGN=\"top\">") +
"</TR>\r\n</TABLE>"

function split(item) {
item = String(item)
return item.replace(
/([;\n])/g,"$1<BR>"
).replace(
/(,)/g,"$1 "
).replace(
/(&)/g,"&<BR>&nbsp;&nbsp;&nbsp;"
)
}
}

<%=showServerVariables()%>

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Jul 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: ruju00 | last post by:
I am getting an error in Login() method of the following class FtpConnection public class FtpConnection { public class FtpException : Exception { public FtpException(string message) :...
1
by: iwdu15 | last post by:
hi, how can i get the icon associated with a certain file type? thanks -- -iwdu15
5
by: tshad | last post by:
I have the following class in my VS 2008 project that has a namespace of MyFunctions. ********************************* Imports System Imports System.Text.RegularExpressions Namespace...
9
vikas251074
by: vikas251074 | last post by:
I am not getting date value in spite of my good effort. This code was working in my last office where I work. Now I am trying to work at my home pc. but not getting date value. Any can help me why...
7
vikas251074
by: vikas251074 | last post by:
I am getting error above in following code since few days giving tension day and night. How can I solve this? I am facing since Oct.25. in line no. 362 After doing a lot of homework, I am...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.