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

get the HTTP command parameter in cfml

New Here ,
Sep 22, 2010 Sep 22, 2010

How to get the HTTP command parameter in cfml?

e.g.

if the HTTP command is

GET /DATA/pg/index.cfm?lang=en HTTP/1.1

then the parameter should be

lang=en

if the HTTP command is

GET /DATA/pg/index.cfm?lang=fr HTTP/1.1

then the parameter should be

lang=fr

TOPICS
Getting started
1.5K
Translate
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

correct answers 1 Correct answer

Enthusiast , Sep 22, 2010 Sep 22, 2010

Try creating a file named "cgitest.cfm" with the content:

<cfoutput>#cgi.query_string#</cfoutput>

Browse to http://localhost/cgitest.cfm?lang=en  (or substitute the appropriate path on your server).

The fact that HTTP_REFERER is populated makes me suspect that you have some redirection code, such as CFLOCATION, in your index.cfm file.

Translate
Enthusiast ,
Sep 22, 2010 Sep 22, 2010

I think that cgi.query_string is what you're looking for.

http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7785.html

Translate
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
New Here ,
Sep 22, 2010 Sep 22, 2010

I put
<cfdump var="#cgi#">
<cfdump var="#http#">
<cfdump var="#url#">
in index.cfm.


HTTP_REFERER returns
/DATA/pg/index.cfm?action=edit

QUERY_STRING returns
action=edit

I do not see "lang=en" anywhere.

Translate
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
Enthusiast ,
Sep 22, 2010 Sep 22, 2010

Try creating a file named "cgitest.cfm" with the content:

<cfoutput>#cgi.query_string#</cfoutput>

Browse to http://localhost/cgitest.cfm?lang=en  (or substitute the appropriate path on your server).

The fact that HTTP_REFERER is populated makes me suspect that you have some redirection code, such as CFLOCATION, in your index.cfm file.

Translate
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
New Here ,
Sep 22, 2010 Sep 22, 2010

Yes, there is <cflocation> in index.cfm.

Although I put cfdump before <cflocation>, cfdump still display QUERY_STRING as

"action=edit"
index.cfm is:

<cfdump var="#cgi#">

<cfdump var="#http#">

<cfdump var="#url#">

<cfif NOT IsDefined("action")>

<cfset action = "edit">

<cflocation url="index.cfm?action=#action#" addtoken="No">

<cfabort>

</cfif>

How to get the original parameter "lang=en"?

Do I still create the "cgitest.cfm" page?

My coldfusion version is 6.1.

Translate
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
LEGEND ,
Sep 22, 2010 Sep 22, 2010

Do one thing at a time.

Get rid of the cflocation until you know what is in your query string.  Once you have it sorted out, create the necessary session variable and use that on your next page.

Translate
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
New Here ,
Sep 22, 2010 Sep 22, 2010

What is the session variable(s) look like?

Should it be stored in the index.cfm and/or the calling page?

Translate
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
Enthusiast ,
Sep 23, 2010 Sep 23, 2010
LATEST

I'm not sure I understand your question. Can you provide some more specific information about what your are trying to accomplish?

You might start by reviewing the CF documentation on session variables.

http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7fd4.html

Translate
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