Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

233
Vistas
how to get the array in servlet which passed from ajax call

I am passing an array from servlet through ajax call. But when I am trying to get the same in servlet side, I am getting null pointer exception. I tried using one of the examples given in SO. Since I'm a newbie, any help would be appreciated!

$.ajax({
				url : 'insertserv1',
				type: 'POST',
				dataType: 'json',
				data: {tablearray:tablearray} ,
		        contentType: 'application/json',
		        mimeType: 'application/json',
				success : function(data) {
							alert('Hi');
						}			
		    });

// to get data from inspection table
		{ var tablearray = [];
			$("#tab_logic tr.data").map(function (index, tr) {
            $(this).find('td').each(function(){
                var $data = $(this).html();
                	if($(this).find("select").length > 0) {
                        var $x = $(this).find("select").val();
                    }else{
 	                	var $x = $(this).find("input[type='text']").val();
 	             	}
                	tablearray.push($x);
            });  	
         });
		}

String[] tablearray = request.getParameterValues("tablearray[]");
		
for (int i = 0; i < tablearray.length; i++) {
  System.out.println(InspTableArray[i]);
}

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

If I have understood correctly, this is what you would be looking for:

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
    JSONObject jObj = null;
    StringBuilder sb = new StringBuilder();
    BufferedReader br = request.getReader();
    String str = null;
    while ((str = br.readLine()) != null)
    {
        sb.append(str);
    }
    try
    {
        jObj = new JSONObject(sb.toString()); //This is your JSON data.
    }
    catch (JSONException e)
    {
        e.printStackTrace();
    }
}
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda