Aravind,
First of all, note that it's horrible practice to have large chunks of code in a
JSP. Good practice would have no code, but static methods are even worse. It makes debugging and maintenance very difficult.
In this particular case, the whole thing should be a
servlet and there should be no JSP. After all, if you have a PDF, you shouldn't have HTML too. What would the browser do wit that?
Try copying that large method into a servlet and printing the result to the output.