I am using Extjs 4 and Java Servlets in my app. I want to post some data to the server in json format.
The format of JSON should be like this:
{
"credentials":[
{
"username":"george",
"password":"xyz"
}
]
}
I did this in extjs code:
buttons: [{
text: 'Submit',
handler: function() {
Ext.Ajax.request({
url: '/Model/FormServlet',
method: 'POST',
jsonData : {
//Hardcoded values
username: "george",
password: "xyz"
},
callback: function (options, success, response) {
alert(response.responseText);
}
});
}
}]
1) I believe that I wont get the JSON format which I posted above. Please let me know how to get that format using jsonData
.
2) How to retrieve this in servlet doPost method? Since I have not used params
and have replaced it with jsonData
hence request.getParameter
is not going to work in the servlet doPost
method.
Please let me know how to make this work.
Regards,