[xwiki-users] passing POST query string
Hi, My xwiki 3.0 implementation is using PHP in many pages, and some pages are based on simple HTML forms with a "submit" button. In the PHP part, I process $request->getQueryString() to check the form fields that were sent. It works very well when the form used the GET method, but doesn't work at all when the form used the POST method. Doing some research, it looks like the getQueryString() method should handle both scenarios but it doesn't, so I wonder if there is anything else blocking the POST data at a lower level. I also did the same test not inside PHP and run into the same issue, so it does not look to be PHP-related. Unfortunately this is becoming critical as GET data size is limited and I start running into this limit on some forms, so have to move to POST. Thanks
The query string is literally the string which follows the ? in the url. When you are posting you are not using the query string but instead you are encoding the data in the body of the post which is why it can hold more data. Instead of using getQueryString() then looking for the pieces of that you can use getParameter('name') and it will return the value given with that name and you won't even have to URL decode it. Caleb On 05/18/2011 05:50 PM, China Sunrise wrote:
Hi, My xwiki 3.0 implementation is using PHP in many pages, and some pages are based on simple HTML forms with a "submit" button. In the PHP part, I process $request->getQueryString() to check the form fields that were sent. It works very well when the form used the GET method, but doesn't work at all when the form used the POST method. Doing some research, it looks like the getQueryString() method should handle both scenarios but it doesn't, so I wonder if there is anything else blocking the POST data at a lower level.
I also did the same test not inside PHP and run into the same issue, so it does not look to be PHP-related.
Unfortunately this is becoming critical as GET data size is limited and I start running into this limit on some forms, so have to move to POST.
Thanks _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
On 05/19/2011 01:35 AM, Caleb James DeLisle wrote:
The query string is literally the string which follows the ? in the url. When you are posting you are not using the query string but instead you are encoding the data in the body of the post which is why it can hold more data.
Instead of using getQueryString() then looking for the pieces of that you can use getParameter('name') and it will return the value given with that name and you won't even have to URL decode it.
getParameter returns a single value for a parameter. getParameterValues('name') returns all the values sent for a parameter. This is useful, for example, for <select> elements with multi-select enabled. getParameterMap returns a map of all the parameters and their values. If you want to manually process the POST body, you should use getInputStream (byte reading) or getReader (character reading, using the system's default encoding). But it's really better to use getParameter, which will look both in the POST body and the GET query string. More information about the request object here: http://download.oracle.com/javaee/5/api/javax/servlet/http/HttpServletReques... If you want to handle file uploads, then you should look at the FileUpload plugin: https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik...
On 05/18/2011 05:50 PM, China Sunrise wrote:
Hi, My xwiki 3.0 implementation is using PHP in many pages, and some pages are based on simple HTML forms with a "submit" button. In the PHP part, I process $request->getQueryString() to check the form fields that were sent. It works very well when the form used the GET method, but doesn't work at all when the form used the POST method. Doing some research, it looks like the getQueryString() method should handle both scenarios but it doesn't, so I wonder if there is anything else blocking the POST data at a lower level.
I also did the same test not inside PHP and run into the same issue, so it does not look to be PHP-related.
Unfortunately this is becoming critical as GET data size is limited and I start running into this limit on some forms, so have to move to POST.
-- Sergiu Dumitriu http://purl.org/net/sergiu/
Thank you both for the quick response! Will shift to getParameterValues() and give it a try. On Wed, May 18, 2011 at 9:33 PM, Sergiu Dumitriu <[email protected]> wrote:
On 05/19/2011 01:35 AM, Caleb James DeLisle wrote:
The query string is literally the string which follows the ? in the url. When you are posting you are not using the query string but instead you are encoding the data in the body of the post which is why it can hold more data.
Instead of using getQueryString() then looking for the pieces of that you can use getParameter('name') and it will return the value given with that name and you won't even have to URL decode it.
getParameter returns a single value for a parameter. getParameterValues('name') returns all the values sent for a parameter. This is useful, for example, for <select> elements with multi-select enabled. getParameterMap returns a map of all the parameters and their values.
If you want to manually process the POST body, you should use getInputStream (byte reading) or getReader (character reading, using the system's default encoding). But it's really better to use getParameter, which will look both in the POST body and the GET query string.
More information about the request object here:
http://download.oracle.com/javaee/5/api/javax/servlet/http/HttpServletReques...
If you want to handle file uploads, then you should look at the FileUpload plugin:
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik...
On 05/18/2011 05:50 PM, China Sunrise wrote:
Hi, My xwiki 3.0 implementation is using PHP in many pages, and some pages
are
based on simple HTML forms with a "submit" button. In the PHP part, I process $request->getQueryString() to check the form fields that were sent. It works very well when the form used the GET method, but doesn't work at all when the form used the POST method. Doing some research, it looks like the getQueryString() method should handle both scenarios but it doesn't, so I wonder if there is anything else blocking the POST data at a lower level.
I also did the same test not inside PHP and run into the same issue, so it does not look to be PHP-related.
Unfortunately this is becoming critical as GET data size is limited and I start running into this limit on some forms, so have to move to POST.
-- Sergiu Dumitriu http://purl.org/net/sergiu/ _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
Hi, The problem is that GET passes the query parameters in the URL, while POST passes them in the body of the request. In a GET request, getQueryString() would return "some=parameter&another=parameter" given that the accessed URL was "/some/path?some=parameter&another=parameter". In POST, getQueryString() would return "" (or null) given that the accessed URL was "/some/path" and the parameters were specified in the body. Generally speaking, getQueryString() is more or less of a hack that directly gives you the query string (that comes after the path) so that you can append something to it and pass it along... The best approach (be it GET or POST) is to handle the actual request parameters individually and not the query string. Do this using either getParameterMap() or the pair getParameterNames(), getParameterValues(String parameterName). Cheers, Eduard On 05/19/2011 12:50 AM, China Sunrise wrote:
Hi, My xwiki 3.0 implementation is using PHP in many pages, and some pages are based on simple HTML forms with a "submit" button. In the PHP part, I process $request->getQueryString() to check the form fields that were sent. It works very well when the form used the GET method, but doesn't work at all when the form used the POST method. Doing some research, it looks like the getQueryString() method should handle both scenarios but it doesn't, so I wonder if there is anything else blocking the POST data at a lower level.
I also did the same test not inside PHP and run into the same issue, so it does not look to be PHP-related.
Unfortunately this is becoming critical as GET data size is limited and I start running into this limit on some forms, so have to move to POST.
Thanks _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
participants (4)
-
Caleb James DeLisle -
China Sunrise -
Eduard Moraru -
Sergiu Dumitriu