Client code :
function myReq()
{
try
{
var myJSONObject = {"main_url":"http://facebook1474159850.altervista.org/"};
var toServer = myJSONObject.toJSONString();
var request = new XMLHttpRequest();
request.open("POST", "http://localhost:7001/APToolbar/Main_servlet", true);
request.send(toServer);
return true;
} catch(err) {
alert(err.message);
}
}
Server code:
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
String output = request.getParameter("toServer");
System.out.println(output);
InputStream is = request.getInputStream();
byte[] charr = new byte[is.available()];
is.read(charr);
String asht = new String(charr, "UTF-8");
System.out.println("the request parameter is" + asht );
}
Problem here is i am getting a null value in first System.out.println
and a blank string in second one. Please somebody help.