I was pulling my hair out trying to figure out an error I was getting with the following code:
<!--- Include public style sheet. ---> <cfset GetPageContext().Include( "../../../linked/css/main.css" ) />
This line of code kept throwing the error:
After literally an hour and a half of playing around with "../" combinations and outputting FileExists() results, I switched over to using a CFInclude tag:
<!--- Include public style sheet. ---> <cfinclude template="../../../linked/css/main.css" />
For some reason, this include works, and the include method of the GetPageContext() servlet does NOT work. I have no idea what this means. As I am not a professional Java programmer, I am not familiar with servlets and context objects. I don't know if it has something to do with web-visibility. I know that the include above were crossing over a virtual directory (an admin area was pulling the CSS file from the public site and the admin was in a virtual directory).
Who knows. I tried to Google some information about page context and I came up with this Java class, but that doesn't really help me understand. Maybe someone out there can help.
As part of my mentality, I was doing it this way so that the main.css file would be included without being parsed. As far as I know, a CFInclude tag will actually parse the file looking for ColdFusion code (even in a CSS file). I had no need to parse the file and was told that the Include() method would not do so.
Want to use code from this post? Check out the license.