1) I updated the title of your post: "help" isn't a very useful title.
2) This is just one of the many very good reasons why doing this type of processing in a JSP is a very bad idea: it's incredibly difficult to debug. My first piece of advice would be to factor the Java out of your page into a servlet controller, or at least a bean.
The NPE is occurring at line 61 of the java class that the JSP container created on behalf of your page (main.jsp). You can find this class as a debugging aid. [ February 24, 2005: Message edited by: Bear Bibeault ]
Tony, A bean is just a java class. You stick all the java code into that class and then call the class from a JSP.
For a homework assignment, it isn't as important to keep code out of the JSP. Especially if you are just getting started. But it is something to keep in mind for when you work an a real project and it is a good habit to get into.
As Bear said, look to see what line 61 is in the compiled JSP class. I suspect it is throwing an exception when getting the connection. Then it finishes the try/catch block and has a null connection.
If you are leaving the code in the JSP, try rewriting it as:
Also, note that it is good practice to have a finally block to close the connections.
Tony, This is occuring because an exception is being thrown. I reposted your code with some comments as to what is happening.
Since an uncaught exception (null pointer) is thrown the stream never gets to flush the output of why it could not obtain a connection. The helpful message as to why is being lost. Try rewriting the code as in my previous post so you can see the reason the connection cannot be obtained. This will be immensely valuable in determining the real problem.