Where you are facing difficulty ? try to implement something then we will help you.But you need to submit the form from jsp to servlet. In servlet you can write some logic then you can use sendredirect to redirect to jsp. dont forget to make entries in web.xml for your servlet.
You will find many example on internet for the same.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com