Passing JSP date to Servlet

0

I have a Datepicker bootstrap as below, and I have a button that should pass the date selected in the datepicker to the Servlet that will use this date as the parameter for a mysql search. How can I pass this date to Servlet? I have tried several examples that I found on the web, but without success.

Button:

<img src="IMG/check.png" style="cursor:pointer" onclick="UpdateGrafico();" />

Datepicker:

<!--datepicker1 -->
   <div class="container" style="width: 100%; 
        margin: 0.5em auto; 
        padding: 1em;
        border: 1px solid greenyellow; 
        border-radius: 0.5em">
    <div class="row">
        <div class='col-sm-3' style="margin-left:10px;">
            <div class="form-group">
                <div class='input-group date' id='datetimepicker1' >
                    <input type='text' class="form-control" id="d"/>
                    <span class="input-group-addon">
                        <span class="glyphicon glyphicon-calendar"></span>
                    </span>
                </div>
            </div>
        </div> 

        <img src="IMG/check.png" style="cursor:pointer" onclick="UpdateGrafico();" />
        <script type="text/javascript">
            $i(function () {
                $i('#datetimepicker1').datetimepicker({
         format: 'DD/MM/YYYY HH:mm'
    });

            });
        </script>

    </div>
</div>
<!--datepicker1 -->
    
asked by anonymous 12.07.2017 / 03:23

1 answer

0
function UpdateGrafico(){

   document.getElementById("loading").style.display = "block";      
       var queryObject="";
       var queryObjectLen="";  
       var processed_json = new Array(); 
       var processed_temp = new Array();
    $j(function () {

                //---------------------

      $j.ajax({  
     data: "",  
     dataType: 'json',  
     url: './GetValores',  
     type: 'POST',  
     success: function(data){  

          queryObject = eval('(' + JSON.stringify(data) + ')');
          queryObjectLen = queryObject.jsonArray.length;


   for(var i=0; i < queryObjectLen;i++){ 

                    var corrente = queryObject.jsonArray[i].valorCorrente;
                    var id = +new Date(queryObject.jsonArray[i].pk);
                    var tmp = queryObject.jsonArray[i].temp;




                    processed_json.push([id, corrente]);  
                    processed_temp.push([id,tmp]);

                }

                //alert(ini);
                //alert(fim);
               if(queryObjectLen === 0){
                    alert("Sem dados para o período pesquisado!");
                }

                //---------------------
                     Highcharts.setOptions({global: { useUTC: false } });     
                    // draw chart

                    $j('#container').highcharts({

                    chart: {
                        type: "spline",
                        zoomType: 'x',
                        backgroundColor: '#d8f5ac'
                    },
                    title: {
                        text: "Current data"
                    },                    
                    xAxis: {
                        type: 'datetime',
                        // max :ini /** Date in timestamp for the end the day */,
                        // min : fim/** Date in timestamp for the beginning the day */,
                        //categories: 'datetime',

                        allowDecimals: true,
                        tickInterval: 3600 * 1000,
                        dateTimeLabelFormats: {
            day: '%d/%b '

        },

                        title: {
                            text: null
                        }

                    },
                    yAxis: {
                        title: {
                            text: "Value (A)"
                        }
                    },
                    plotOptions: {
            series: {
                turboThreshold: 0, //libera para plotar mais de 1000 pontos no chart

            }
        },

                    series: [{
                    name: 'Valor de corrente',
                        data: processed_json,
                        color: '#FF0000'
                    },{
                        name: 'Temperatura',
                        data: processed_temp   
                    }

            ]


                }); 
             document.getElementById("loading").style.display = "none";//oculta div de loading
           //----------
            },  

     error: function() {  

       alert("Ocorreu um erro na requisição ajax");  
     }  
   });
           //----------

        });
    }
    
14.07.2017 / 01:27