This was actually an excellent interview question. It's also one that shouldn't be answered, at least directly, in forum like this. Doing so contributes to that class of people who know just enough to get themselves in trouble.
JSP, on the surface, looks very similar to ASP or PHP. Under the surface, there are some very important differences. Thinking that your knowledge of one of those scripting language is enough preperation for you to take a job as a JSP developer is an easy trap to fall into.
It was an excellent interview question for this reason: If an interviewee can't answer it off the top of her/his head then they don't understand the the most important difference -- the one that leads to the type of threading issues seen above. Asking "how would you create an instance variable" might have tipped the interviewee off.
If you plan on working with JSP, and don't fully understand what parts of your code will be translated into service code and which parts will be translated into instance code, then someone, handing the answer to you, is not doing you any favors.
Sit down and read a book, cover to cover, build a few apps that use the examples from the books and play with them. Better yet, learn servlets. The concepts that you'll need to understand to write proper JSP code are laid out in plain sight in a servlet. Some JSP/Servlet engines, by default, keep the code generated from your JSPs (Tomcat). If you've already learned servlets then looking at the generated code will show you exactly what becomes of your JSP scriptlets.
My first impluse when an easy question is posted is to show off that I know the answer. What's better, and harder to do, is to turn the question into a longer discussion in which the reader actually learns something.
In this case, Bear did it right by waiting until someone gave a "less than complete (although perfectly correct) answer" and then stepped in. [ January 20, 2005: Message edited by: Ben Souther ]
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com