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