i need to call servlet post method using javascript ,i have done like this
var iframe= document.getElementById("iframe");
iframe.src = "MyServlet";
You have done it incorrectly.
You need to set the src to a URL that will invoke the servlet, such as
iframe.src = "/Path/To/Something";
If you want to send a POST request, you'll need to create a <form action="/Path/To/Something" target="IFrameName"> and call submit().
Note that it is more efficient to use AJAX, with an XMLHttpRequest. The easiest way to do that is with jQuery:
$.get("/Path/To/Something");
(Although you would want to call $.post)
post(..) (it's what he wants)