javajsptomcatdojorequest-uri

Encountering 414 Request-URI Too Large when passing a really long URI using Dojo's dojox.layout.ContentPane


My app is a Java Tomcat WebApp that uses Dojo js toolkit as our framework for our web pages. One of my form pages involve passing a huge chunk of string data to another form page using Dojo's dojox.layout.ContentPane. ContentPane passes all the parameters and loads the corresponding page using GET but causes 414 Request-URI Too Large as this exceeds Apache's LimitRequestLine

I have read that using POST HTTP method would solve this altogether but ContentPane does not seem to support it. Accepting any possible solutions or workarounds for this

Found out about ContentPane.ioMethod from 'tk' in Dojo IRC #dojo

<div class="contentPanel" id="contentPanel" data-dojo-type="dojox/layout/ContentPane" data-dojo-props="**ioMethod: dojo.xhrPost**">

The following works for passing a proper POST form data to the ContentPane via ioArgs:

var obj = {val1: val1}
registry.byId("contentPanel").set("ioArgs",{content: obj}); 
registry.byId("contentPanel").setHref("whateverPage");

Hope this helps someone else


Solution

  • You can override the XHR method a ContentPane instance uses by setting its ioMethod property (which defaults to dojo/_base/xhr.get). Setting it to xhr.post will cause it to send a POST request instead.

    (Note that you should pass it a method from dojo/_base/xhr, not dojo/request/xhr, since ContentPane interacts with the old API.)