Honestly, this code could just be copied and pasted straight into a
java class, and it will work exactly the same way.
You are doing NOTHING here that requires a JSP.
Putting this code into a java class in Eclipse will actually help you diagnose the problem. Compilation will fail because the required classes aren't in the classpath.
You can fix up the problems at compile time, rather than runtime which is a LOT easier with the
IDE to help you.