Weird HTTP Error, HTTP Request Parameter Not Detected When Using JavaScript canvas.toDataURL and Base64 Ajax Post
I have a simple Java web application that use Ajax image upload using canvas.toDataURL and base64 encoder. Usually it run well, but I have a very weird error that happen intermittently. Somehow my application cannot detect any http request parameters that send by my Ajax requests. After I spend a while researching, it seems that this error only happen when uploading multiple big images.
At first I thought that it was my Java or JavaScript issue, but then I realized that this is an issue on my Application Server, which is Apache Tomcat. Its default value for maximum POST size is 2MB (2097152), and after I resize it, the error went away.
I add “maxPostSize” property on server.xml, to increase maximum POST size that Apache Tomcat can handle. In this example, i increase it into 20MB.
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443" maxPostSize="20971520"/>
😉