ASP - Active Server Pages

Does URL Exist?

Does http://educ.jmu.edu/~johns2ja/BOO.jpg exist?

It exists!

 

Does http://educ.jmu.edu/~johns2ja/BOOTS.jpg exist?

It does not exist!

 

Code used:

<% 
//
// URL to be checked
//
CheckURL = ("http://educ.jmu.edu/~johns2ja/BOO.jpg")
CheckForURL(CheckURL)
CheckURL = ("http://educ.jmu.edu/~johns2ja/BOOTS.jpg")
CheckForURL(CheckURL)
// 
// create an XMLHTTP object that is the vehicle for the page check
//
Sub CheckForURL(myURL)
  response.write "<p>Does " & CheckURL & " exist?</p>"
Set GetConnection = CreateObject("Microsoft.XMLHTTP")
// 
// open a path to the chosen URL and attempt to send data to it
//
GetConnection.Open "get", CheckURL, False 
GetConnection.Send()
// 
// check the return code, 200 means OK
//
if GetConnection.status = 200 then
response.write("It exists!")
else
response.write ("It does not exist!")
end if
//
// get rid of the XMLHTTP object 
//
Set GetConnection = Nothing
response.write "<p>&nbsp;</p>"
End Sub
%>
Tidbits | ASP Home | ASP - Basic Notes | VBScript Basics | JavaScript in ASP | e-mail | Jedi Knight Radio Button | Jedi & Sith Names | Get Your Info | Get Text File | Browser | HTML Encode | Piggyback | Script Timeout | Timed Session | Map Path | ASP Login | Random Quote | Params | Dates & Time | In an Array? | Search Form | Does URL Exist? | ASP Database