This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Step 1: move the Java code out of the JSP and into a servlet that the form will submit to. Modern JSPs should never have Java code in them, and here, you're trying to process the form before it even gets a chance to be seen at the browser.
Step 2: Always check parameters for null. Nothing guarantees that they'll have a value.