As you are using callable statements over a Stored proc. That stored proc might return some parameters. To get these parameters in your Java variables, you have to first register these parameters.
Are you picking up these values from the database and then trying to show them ? Or are you hard coding the values in the pages ? Using DB, one easy way of doing it wud be to to show the 10/20/50 values on each page and do a next which grabs the next 50 values. You can write a simple Javabean method which does so or in the same JSP, you can submit the request with these paramters, and do getParameter() in the beginning of the page and retrieve values.
Let me know if u want to do it with Db... I have worked quite a lot on it
In your code, you are trying to distinguish between Odd and Even numbers which is increasing the complexity.
Better way could have been to use an integer and increase it by one always. This increase of number and writing to a file can be pushed to a synchronized block/method.
It would make sure that you are writing them one by one. make the threads sleep for a while.
Basically, create a single class and invoke 2 instances of that class thread and then make them write. Makes sense ?
Are you getting all the 20 questions in one go ? I mean, are you using the resultset to return you all 20 questions. You display them on the JSP and then the user picks up one of them ? If that is the case, when the user picks up some other state, you can just fire another query using a Statement object.