I have a javascript object that i want to pass to a java Servlet, how can i perform this operation ? I have already tried few things but didnt work out.
Here is my code :
$.ajax({
url: 'TestUrl',
data: {
object: myJavaScriptObject
},
type: 'GET'
});
and in the servlet (doGet method)
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String result = request.getParameter("object");
System.out.print(result);
}
but i just get null in the console.
I'm also interested on how to perform the opposite operation, pass a java object in the servlet to a JavaScript Object.
Thank you in advance.