• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

CGI.PATH_INFO is blank in CF 10

Explorer ,
Feb 21, 2013 Feb 21, 2013

Copy link to clipboard

Copied

I know this was an issue that was supposedly fixed in the first update, but I applied that and I'm still experiencing the error.  Any ideas?

Version says ColdFusion 10,283649

Views

34.0K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Mar 13, 2013 Mar 13, 2013

Copy link to clipboard

Copied

Updated: Changed "In the 1st example" to "In the examples".

Hi ColdFusionSmurf and Sue,

Anit is, of course, correct (thus the repeated answer). The "directory structure" and "extra path info" both refer to different parts of the request's URL.  Neither CGI.SCRIPT_NAME is the "/the/directory/structure/scriptname.cfm", which I believe was the desired part of the URL?  I will try to further explain..

Example*: http://domain.com/the/directory/structure/scriptname.cfm/extra/path/info;jsessionid=the_jsessionid_here

CF9's CGI.SCRIPT_NAME: /the/directory/structure/scriptname.cfm

CF9's CGI.PATH_INFO: /extra/path/info

CF9's getPageContext().getRequest().getRequestURI(): /the/directory/structure/scriptname.cfm/extra/path/info;jsessionid=the_jsessionid_here

CF10's CGI.SCRIPT_NAME: /the/directory/structure/scriptname.cfm

CF10's CGI.PATH_INFO: /extra/path/info

CF10's getPageContext().getRequest().getRequestURI(): /the/directory/structure/scriptname.cfm/extra/path/info;jsessionid=the_jsessionid_here

Example*: http://domain.com/the/directory/structure/scriptname.cfm;jsessionid=the_jsessionid_here

CF9's CGI.SCRIPT_NAME: /the/directory/structure/scriptname.cfm

CF9's CGI.PATH_INFO: /the/directory/structure/scriptname.cfm;jsessionid=the_jsessionid_here (incorrect - pre-CF10 bug)

CF9's getPageContext().getRequest().getRequestURI(): /the/directory/structure/scriptname.cfm;jsessionid=the_jsessionid_here

CF10's CGI.SCRIPT_NAME: /the/directory/structure/scriptname.cfm

CF10's CGI.PATH_INFO: [empty string] (correct - CF10 fixed the bug)

CF10's getPageContext().getRequest().getRequestURI(): /the/directory/structure/scriptname.cfm;jsessionid=the_jsessionid_here

1) Using getPageContext().getRequest().getRequestURI() may not always return the desired result.

2) Using CGI.PATH_INFO to get the /the/directory/structure/scriptname.cfm was incorrect, and CF10 corrected this.

I'd recommend, in Application.cfm/cfc:

<cfscript>

  REQUEST.cgi = duplicate(CGI);

</cfscript>

And then, in code, prefix CGI variables w/ "REQUEST.cgi." instead of "CGI.".

If that had been done, then a workaround (until existing code could be fixed) would've been as simple as (in Application.cfm/cfc):

<cfscript>

  REQUEST.cgi = duplicate(CGI);

  if(!len(REQUEST.cgi.path_info)) {

    REQUEST.cgi.path_info = REQUEST.cgi.script_name;

  }

</cfscript>

* - The JSessionID is appended by urlSessionFormat() if J2EE sessions are enabled, and if cookies are disabled in the browser, and if the session scope is enabled for the Application.

Note: In the examples, the ".cfm" (or any extension) is actually optional, if web.xml (and uriworkermap.properties in CF10) contain(s) a mapping for the extensionless file. That can be helpful for setting up URLs such as http://domain.com/go/extra/path/info. But that is beyond the scope of this issue.

Thanks,

-Aaron

Message was edited by: itisdesign Removed "Neither" (red).  Added CGI.SCRIPT_NAME and the missing part of the example URL throughout the discussion (green).  I was updating the Example URLs to make multiple points and ended up making neither point correctly.  The main points were: 1) CGI.PATH_INFO is the "*extra* path info" which _follows_ CGI.SCRIPT_NAME.  2) Pre-CF10, CGI.PATH_INFO incorrectly returned CGI.SCRIPT_NAME, and sometimes JSessionID, if "extra path info" didn't exist.  3) CGI.SCRIPT_NAME is the variable to use, as per the code example below.  4) getPageContext().getRequest().getRequestURI() sometimes includes JSessionID, so caution should be used when using this to essentially get CGI.SCRIPT_NAME.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 14, 2013 Mar 14, 2013

Copy link to clipboard

Copied

Actually the information ColdFusionsmurf provided allowed me to fix the code the the breadcrumbs code I was trying to run.  I had NO interest in the final page.  I'm on the final page when I'm putting the breadcrumb info on it.  What I was looking for is building links to the directories above it, so that I had a true breadcrumb.

The code worked under CF9 and broke under CF10 giving me NOTHING in that field regardless of where in the directory tree structure I called it from. 

With the changes ColdFusionsmurf suggested, it is working, though it is showing the final page, which I didn't have before, not needed but at least it's not breaking anything.

You can see the resultant breadcrumb on this page:

home  »  English
»  committees
»  communications
»  2012
»  report-sept-2012.cfm

http://www.ute-sei.org/English/committees/communications/2012/report-sept-2012.cfm

I still believe that CF10 is broken, since NOTHING would show on a page like the one above in CF10 and it would in CF9 and I have had to write a workaround.

Sue

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Mar 15, 2013 Mar 15, 2013

Copy link to clipboard

Copied

Hi Sue,

Could you please also try getDirectoryFromPath(CGI.SCRIPT_NAME) ?

Btw, I've updated my last post (explained in the comment at the bottom of it) in order to correctly clarify my points.  Sorry about the mistakes in my last post.

Thanks,

-Aaron

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation