在jsp页面中使用postdata

I have a form in my jsp page, and I have to capture the POST variables when clicking ok button and print them.

I think my solution is Ajax,but I'm not able to get it.

 <html>
 <head>
  <meta http-equiv="Content-Type" content="text/html"; charset="ISO-8859-1">
   <title>Ejemplo de carga de datos</title>
   <script src="/Scripts/jquery-1.9.1.js"></script> 

 <script>
     $(function(){ 
        $(document).ready(function () {
           $('input[type="submit"]').click(function (event) {

             var url = "datos.jsp"; // El script a dónde se realizará la petición.

    $.ajax({
       type: "POST",
       url: url,
       data: $("#form").serialize(), // Adjuntar los campos del formulario enviado.
       success: function(data)
       {

       }

     });


        });

    });
});

 </script>
</head>
    <body>


     <form name="form" id="form"  method="post" enctype="multipart/form-data" >
     <textarea cols=50 rows=10 name="texto" id="texto"></textarea>  

     <input type="submit" name="submit" value="Enviar datos" />

     </form>

 </body>
</html>

And datos.jsp:

  <%

      String texto = request.getParameter(texto);

      System.out.println(texto)

       %>

But it doesnt work How can I do it?

I add @Aleksey Bykov's sugestion.

 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

 <html>
  <head>
     <meta http-equiv="Content-Type" content="text/html"; charset="ISO-8859-1">
        <title>Ejemplo de carga de datos</title>

          <script src="https://code.jquery.com/jquery-1.10.2.js"></script>

       <script>
    $(function(){ 
       $(document).ready(function () {
       $('input[type="submit"]').click(function (event) {



            var textoVar = $('#texto').val();
            alert(textoVar);
    $.ajax({
        url: 'page.jsp',
        type: 'POST',
   dataType: 'json',
        data: {
            texto: textoVar
        },
        success: function (data) {
            //
        },

        failure: function (data) {
            //
        }



    });

});
});
});
 </script>
</head>
<body>


    <span>Sent via AJAX: <b><c:out value="${param.texto}" /></b></span>


    <form name="form" id="form"  method="post" enctype="multipart/form-data" >
     <textarea cols=50 rows=10 name="texto" id="texto"></textarea>  

     <input type="submit" name="submit" value="Enviar datos" />


    </form>

</body>

It always prints ${param.texto} (this line not the value), even without send the form.

Do you have to use Javascript? This can be done by just adding an action to the form for skipping all the ajax stuff.

 <form name="form" id="form"  method="post" action="datos.jsp" >
      <textarea cols=50 rows=10 name="texto" id="texto"></textarea>  

      <input type="submit" name="submit" value="Enviar datos" />
 </form>

You can get the value of the texto parameter by using JSTL:

<c:out value="${param.texto}" />

Full example - after clicking the submit button you will see at the top of the textarea the text that you entered.

<script>
    $("#submit").click(function() {
        var textoVar = $('#texto').val();
        $.ajax({
            url: 'YourJspHere',
            type: 'POST',
            dataType: 'json',
            data: {
                texto: textoVar
            },

            success: function (data) {
                //
            },

            failure: function (data) {
                //
            }
        });
    });
</script>

<span>Sent via AJAX: <b><c:out value="${param.texto}" /></b></span>
<form name="form" id="form"  method="post">
    <textarea cols=50 rows=10 name="texto" id="texto"></textarea>
    <input type="submit" name="submit" value="Enviar datos" />
</form>

Before sending:

enter image description here

After sending:

enter image description here