Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FSO objXMLHTTP problem

Status
Not open for further replies.

struth

Programmer
Aug 26, 2001
114
GB
I have this FSO script at the bottom of a records.asp page and it does create the file but not accurately because I need it to reference the page (records.asp) with the posted form data from the referring page included.

I have tried a couple of server variables but these just seem to make the page hang. any ideas?

<%
strURL = &quot;
Set objXMLHTTP = Server.CreateObject(&quot;Microsoft.XMLHTTP&quot;)
objXMLHTTP.Open &quot;GET&quot;, strURL, false
objXMLHTTP.Send

lStrContent = objXMLHTTP.responseText

Set objXMLHTTP = Nothing

lStrPath = Server.MapPath(&quot;\records&quot;) & &quot;\&quot;
lStrFileName = replace(date,&quot;/&quot;,&quot;_&quot;) & &quot;_help.html&quot;

Set objFSO = Server.CreateObject (&quot;Scripting.FileSystemObject&quot;)

Set lStrFileCreate = objFSO.CreateTextFile(lStrPath & lStrFileName, true)
lStrFileCreate.WriteLine(lStrContent)
lStrFileCreate.Close

Set objFSO = Nothing
%>

thanks in advance

&quot;Away from the actual ... everything is virtual&quot;
 
The code looks ok, i've made a test for myself with this one
Code:
strURL = &quot;[URL unfurl="true"]http://www.tek-tips.com&quot;[/URL]
Set objXMLHTTP = Server.CreateObject(&quot;Microsoft.XMLHTTP&quot;)
objXMLHTTP.Open &quot;GET&quot;, strURL, false
objXMLHTTP.Send

lStrContent =  objXMLHTTP.responseText
Set objXMLHTTP = Nothing

lStrPath = Server.MapPath(&quot;records&quot;) & &quot;\&quot;
lStrFileName = replace(date,&quot;/&quot;,&quot;_&quot;) & &quot;_help.html&quot;

Set objFSO = Server.CreateObject (&quot;Scripting.FileSystemObject&quot;)
Set lStrFileCreate = objFSO.CreateTextFile(lStrPath & lStrFileName, true)
lStrFileCreate.WriteLine(lStrContent)
lStrFileCreate.Close
Set objFSO = Nothing

________
George, M
 
shaddow, the problem I've got is that I have a dynamically created form that is submitted to this page. I've got to retrieve those ever changing form values and then attach them to the objXMLhttp url:

I am using this function to grab the requests (and it is) but when I put these into a variable or even session it doesn't see them

Private Function URLDecode(strConvert)

Dim arySplit
Dim strHex
Dim strOutput

If IsNull(strConvert) Then
URLDecode = &quot;&quot;
Exit Function
End If

' First convert the + to a space
strOutput = REPLACE(strConvert, &quot;+&quot;, &quot; &quot;)

' Then convert the %number to normal code
arySplit = Split(strOutput, &quot;%&quot;)

If IsArray(arySplit) Then
strOutput = arySplit(i)
For I = LBound(arySplit) to UBound(arySplit) - 1
strHex = &quot;&H&quot; & Left(arySplit(i+1),2)
Letter = Chr(strHex)

strOutput = strOutput & Letter & Right(arySplit(i+1),len(arySplit(i+1))-2)
Next
End If

URLDecode = strOutput

End Function

And this is where things are cracking. Both functions are working but when I put the two together nada, nothing but errors. When I hand code in the request values ... fine ... but as I said they have to be dynamically resolved.

AHHHHHHHHHHHH!!

&quot;Away from the actual ... everything is virtual&quot;
 
You want to access your form values within the XMLHTTP object page? or you want to send data to the asp page using XMLHTTP object?

________
George, M
 
ER.....both? Maybe this is my problem? My XMLHTTP/FSO objects sit at the bottom of my asp page.... like this

Dynamic form page -> submitted to -> records.asp which displays the outcome of the form ... at the bottom of my records page sits my XMLHTTP/FSO objects which I want to use to create an html record of the just created records.asp but they need that form data to submit again to the records page

records.asp?ID=1&a=1&b=2 etc.

May I should separate them ... form -> XMLHTTP/FSO objects -> records.asp?

Is that any clearer?

Many thanks
struth

&quot;Away from the actual ... everything is virtual&quot;
 
Maybe you should try with a intermediar page.
I think that if you call same page again with XMLHTTP it will get into an endless loop. Also you would need a full path to the requested asp file for XMLHTTP object.
Code:
records.asp it's the intermediar page
<%
strURL = &quot;[URL unfurl="true"]http://localhost/tek/xmlhttp/records1.asp?ID=&quot;&Request(&quot;ID&quot;)&&quot;&a=&quot;&Request(&quot;a&quot;)&&quot;&b=&quot;&Request(&quot;b&quot;)[/URL]
Set objXMLHTTP = Server.CreateObject(&quot;Msxml2.XMLHTTP.5.0&quot;)
objXMLHTTP.Open &quot;GET&quot;, strURL, false
objXMLHTTP.send  
lStrContent =  objXMLHTTP.responseText

'write to the file
lStrPath = Server.MapPath(&quot;records&quot;) & &quot;\&quot;
lStrFileName = replace(date,&quot;/&quot;,&quot;_&quot;) & &quot;_help.html&quot;
Set objFSO = Server.CreateObject (&quot;Scripting.FileSystemObject&quot;)
Set lStrFileCreate = objFSO.CreateTextFile(lStrPath & lStrFileName, true)
lStrFileCreate.WriteLine(lStrContent)
lStrFileCreate.Close
Set objFSO = Nothing

'write back to the user
Response.Write lStrContent
Set objXMLHTTP = Nothing
%>

and response1.asp it's the actual file wich makes the serach.

I've tested this on my machine and works ok.
I'll let the code unchanged to see what i've done.

________
George, M
 
Yup! That's done it. I had avoided the eternal loop with a conditional but separating things out has done the job. Thanks for hanging in there with me.

Struth



&quot;Away from the actual ... everything is virtual&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top