This can only be accomplished using AJAX.
So, on the click of the submit button, display the Loading image, and make the ajax call to the servlet. So while the servlet will be processing, the loading image will be displayed. Uppon returning from ajax call, you can use javascript to do any actions you require (forward user to another page / show errors .. etc).
I highly recommend you to see JQuery Ajax (this is the most easy and effective script I have ever used)
$.ajax({
type: 'POST',
url: '/myServlet',
data: {
name: $('#name').val()
},
beforeSend:function(){
// this is where we append a loading image
},
success:function(data){
// successful request; do something with the data
},
error:function(){
// failed request; give feedback to user
}
});