ColdFusion Programming/Query String Length in CF8

Advertisement


Question
QUESTION: Hi Clint,

I was using CF MX and recently my server was migrated to CF8. one of my programs is using form method="get" and it was working fine. The same source code does not work in CF8.

I came to know that if we use GET method there is a limit on the length of query string. Now I would like to ask you if we can somehow raise such limit in CF8. Could you please let me know? Thanks.

ANSWER: Query string limits have nothing to do with Coldfusion or any other server for that matter, it's a browser issue and I would suggest you convert whatever it is your doing to a POST method. It has always been a general rule in web programming that long query strings use POST instead of GET.

Here's the official ruling:
The spec for URL length does not dictate a minimum or maximum URL length, but implementation varies by browser. On Windows: Opera supports ~4050 characters, IE 4.0+ supports exactly 2083 characters, Netscape 3 -> 4.78 support up to 8192 characters before causing errors on shut-down, and Netscape 6 supports ~2000 before causing errors on start-up.

Note that there is no limit on the number of parameters you can stuff into a URL, but only on the length it can aggregate to.

Keep in mind that the number of characters will be significantly reduced if you have special characters (e.g. spaces) that need to be URLEncoded (e.g. converted to the sequence '%20'). For every space, you reduce the size allowed in the remainder of the URL by 2 characters - and this holds true for many other special characters that you may encode before sending the URL to the client.

Keep in mind, also, that the SGML spec declares that a URL as an attribute value (e.g. <a href='{url}'>) cannot be more than 1024 characters. Similarly, the GET request is stored in the server variable QUERY_STRING, which can have similar limitations in certain scenarios.

If you are hitting a limit on length, you should consider using POST instead of GET. POST does not have such low limits on the size of name/value pairs, because the data is sent in the header, not in the URL. The limit on POST size, by default, is 2 MB on IIS 4.0 and 128 KB on IIS 5.0. POST is also a little more secure than GET -- it's tougher (though not impossible) to tinker with the values of POSTed variables, than values sitting in the querystring.


---------- FOLLOW-UP ----------

QUESTION: Hi Clint,

Thanks for the wonderful explaination. I agree with everything you explained but still my doubt continues as why this works in CF MX but not under CF 8. Do you have any idea why it is so? Because in our production server it still has CF MX and the same source code works there with GET. In our Development server we have recently installed CF 8 for testing and the I came across this problem.

Can you let me know what could be the reason? Thanks again.

Regards
Ganesh

Answer
Having said that the url query string limits are not server related, what I meant to say was that it wasn't Coldfusion server related. The only CFIDE setting for form data is a POST size limitation defaulted to 100 mb that you can alter, but that is all.

It sounds like your pretty set on staying with a url query instead of switching it to a post query. I'm assuming you're not able to change it for a good reason, maybe the page it's posting too can't be changed to accept and process posts, I don't know, but it's too bad. I hate it when departmental policies and red tape keeps you from doing your job.

I would suggest you run this question through the IIS, JRun, or J2EE experts and see if the web server has a setting for this. I'm not a server administrator expert but that sounds like a possibility if there is one. Good luck.

ColdFusion Programming

All Answers


Answers by Expert:


Ask Experts

Volunteer


Clint Willard

Expertise

I will volunteer to answer your Coldfusion programming questions.

Experience

I am an expert certified Coldfusion MX programmer with experience in Flash, Action Script, Flex, SQL, XML, and other related.

Education/Credentials
Associates in Applied Science and Coldfusion MX certificate.

©2012 About.com, a part of The New York Times Company. All rights reserved.