Javascript Posts

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"/>

😉

Creating a Calendar or Date Picker using JQuery

Well, it’s actually quite easy to create a simple calendar or datepicker using jquery. But first you need to download jQuery and jQuery UI libs. This is how you do it,

<html>
    <head>
        <title>JQuery Test</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link href="datePicker.css" type="text/css" rel="stylesheet" />
        <script type="text/javascript" src="jquery.js"></script>
        <script type="text/javascript" src="jquery-datepicker.js"></script>
        <script type="text/javascript">
            $(function()
            {
                $('#date-pick').datepicker({
                    showOn: "button",
                    dateFormat: "dd/mm/yy",
                    disabled: true,
                    buttonImage: "calendar.png",
                    buttonImageOnly: true
                });
            });
        </script>
    </head>
    <body>
        Enter your birthdate :
        <input name="date1" type="text" id="date-pick" size="10" maxlength="10" />
    </body>
</html>

It will look like this,

For the live example, you can see here. Cheers (B)