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.
 
     
    
