I have to work on a project, i.e a website. I will be using jsp, servlets, or may be spring hibernate. I need to ensure that it cannot be hacked. I have no idea about the securities. Please recommend a book for that.
It covers Cross Site Scripting (XSS), which is the most difficult web vulnerability to deal with, but XSS should have its own book. For that reason, I also recommend XSS Attacks. The guys who wrote that one are giants in web app security research.
Those two books will help you understand the attacks. It is up to you to keep current on the new variations on these attacks.