Viral, First, note that it is considered bad practice to put Java code - especially database code - in a JSP. It should be in Java objects.
Have you looked at the logs or what line the NullPointer is thrown on yet?
The following code jumps out at me as a problem. If there is an exception loading the connection, a message is logged and the code continues with the connection set to null. This invites the code to blow up later when someone tries creating a statement from that connection.
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