How to send a javascript array to the Servlet
NickName:lucifer Ask DateTime:2013-12-05T11:28:19

How to send a javascript array to the Servlet

I have an application where i am getting some values in the console in the form of a javascript array.now i want to send the values to the servlet.My javascript array look like this ..

0.Java
1.Perl
2.C#

This values i am getting in the console.i have to send those values to the Servlet.But i can not do that.I am able to send multiple values to the Servlet,but dont know how to send array of javascript.The way i send multiple values to the Servlet is

 $.ajax({
        url: "AccountServlet",
        type: "post",

        dataType: "json",
        data: { subject1:java,subject2:perl..etc},
        error:function(){
            //alert("error occured!!!");
        },
        success:function(data){
            alert(data.fullName + "\n" + data.mobileNo);
        }
     });

and in the Servlet i catch them

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    String sub1=request.getParameter("subject1");
            String sub2=request.getParameter("subject2);
    ;

Like this but can anyone help me how to store array of javascript here. }

Copyright Notice:Content Author:「lucifer」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/20390835/how-to-send-a-javascript-array-to-the-servlet

More about “How to send a javascript array to the Servlet” related questions

How to send a javascript array to the Servlet

I have an application where i am getting some values in the console in the form of a javascript array.now i want to send the values to the servlet.My javascript array look like this .. 0.Java 1.Pe...

Show Detail

How to send JavaScript array to Servlet inside form tag?

I have made checkbox code and on checkbox click I am calling function which will add passed argument to JavaScript array. I have taken form tag inside body and inside form tag there is only checkbo...

Show Detail

How to send Javascript multidimensional array values to Java servlet?

I have store the textbox's value to the multidimensional array in Javascript named as records (below code) and I need to send these array object to my servlet page. But I have no idea about how to ...

Show Detail

How to send byte array from javascript to java servlet through ajax

I have a byte array in front-end generated by javascript that I want to send to java servlet through ajax. How can I do that?

Show Detail

How to send a javascript array to Java servlet

Hello people I'm doing a web application some orthodox, my method is AJAX using java and javascript. And I asking me if is possible set a array from javascript to Servlet.

Show Detail

Using JavaScript to send String to Servlet, and Results from servlet back to JavaScript

First of all: sorry for my bad grammer. English isn't my native language, but i will try to exlpain my problem as simple as i can. I'm working on a web-application, where user can enter a link. (

Show Detail

An array from JavaScript to servlet

I have a problem with receiving data from JavaScript into a servlet. In my page, a user can generate an array with strings (using JavaScript). I want to receive this data into my servlet. I don't h...

Show Detail

read javascript array from servlet

My question is how to read javascript array from servlet Using javascript, I am reading the creating the ArrayList as follows: var data1= new Array(); for(var i=1;i<=count;i++){ var Ob...

Show Detail

How to send an array from Servlet to Java Script with AJAX?

I need send an array to js with ajax, this is my function with ajax in a java script... $.ajax({ url: "/localizacion/ServletPeticiones", type:"Post", data:"accion=LatLong_UR", data...

Show Detail

how to pass the javascript array to servlet

i have requirement i.e., i need to pass array of javascript to servlet. please guide me thanks qwe.js <script type="text/javascript"> var array2 = []; function getTotalTests() { ...

Show Detail