First of all remove all of the database code and put it in seperate methods and classes and call those methods from the jsp.
Then read the exception that you get. It tells you exactly what the error is at line 66
The NumberFormatException is thrown when you cannot convert something to a number:
Integer.parseInt(codigo)
And the stacktrace says: java.lang.NumberFormatException: null
You are trying to write some complex code with out knowing the basics. Handling NumberFormatException and figuring out that you are trying to parse something which is null is very simple. Especially since the exception tells you exactly that. I would like to suggest that you to take one step back.
Forget about jsps and jasper. Try to write simpler codes first and make a lot of mistakes. Seriously that is how you learn to read the stack trace and correct the errors that you get. By making them.
And by trying to execute queries in jsp is an indication that you haven't written many java core programs. Did you always put all of your code in the main method? Or did you have different classes with methods and call those methods in the main. You must do the same here. NO java code in the jsp unless they are used to displying the data or retrieve them and pass them as arguments to methods that do all the work