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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CFFILE read of a served web page

Status
Not open for further replies.

jdaniels

Technical User
Apr 23, 2002
63
0
0
GB
Hi,

I am trying to use CFFILE to read the contents of another coldfusion page, but only the contents after it has been processed (ie turned into an HTML page). I tried the following:

<cffile action=&quot;read&quot; file=&quot; variable=&quot;htmlcontent&quot;>

but was given an stacktrace saying 'file not found' The URL was correct - I tested it in a browser, with no trouble. However using this code with the file value being something on the local filesystem such as 'C:\here\there\this.html' was no problem. The problem is that I want to read the served HTML, after it has been processed by CF.

Any ideas? I am using Win2000, IIS5, CFMX Server 5.

Thanks,

Jonathan Daniels
 
Does the content of the file you're trying to pull have to be live, up to the minute information? If not, you may want to see about scheduling that page and publishing the output to an html page and then have your CFFILE just connect to the html page. You should be able to schedule it to run pretty frequently. I wouldn't be the same as a live query, but it could be updated every 15 minutes or so.

This may not be what you're looking for, just thougt I would offer another approach.

Hope this helps.
 
Yup, it needs to be up-to-the-minute. The way I am going about it is to have CF execute a java class which in turn accesses the URL and writes it to a file. Seems to work ;)

Thanks for your time.

Jonathan Daniels
 
I'm pretty sure you would either have to do a CFINCLUDE, or a CFHTTP for CF to process the code. CFFILE won't do it.

Try:
Code:
<CFINCLUDE template=&quot;/webroot/thispage.cfm?this=that&quot;>

or
Code:
<CFHTTP url=&quot;[URL unfurl="true"]http://www.mysite.com/thispage.cfm?this=that&quot;[/URL] method=&quot;GET&quot; resolveurl=&quot;false&quot;></CFHTTP>

<CFSET htmlcontent=cfhttp.fileContent>

Both will process the CFML, as long as the file extension is .CFM.

CFINCLUDE is going to be faster and less prone to network glitches. If you really need to put the content into a variable using cfinclude, rather than output it immediately, you can do something like:

Code:
<CFSAVECONTENT variable=&quot;htmlcontent&quot;>
  <CFINCLUDE template=&quot;/webroot/thispage.cfm?this=that&quot;>
</CFSAVECONTENT>




-Carl
 
Yup, that did it! Thanks alot for your help.

JD
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top