How can I allow my servlet to accept 4 parameters via HTTP POST through a URL?
Just invoke a HTTP POST request with those 4 parameters.
Either by a simple HTML form.
<form action="servletURL" method="post">
<input type="hidden" name="param1" value="value1">
<input type="hidden" name="param2" value="value2">
<input type="hidden" name="param3" value="value3">
<input type="hidden" name="param4" value="value4">
<input type="submit">
</form>
Or by Ajax (with little help of jQuery).
<script>
var params = {
param1: 'value1',
param2: 'value2',
param3: 'value3',
param4: 'value4'
};
$.post('servletURL', params, function(response) {
alert(response);
});
</script>
Then they'll be available the usual request.getParameter(name)
way in servlet's doPost()
method.