If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

to use or not to use SingleThreadModel?

Hi there,

I wanted to get input on a matter of thread safety for a servlet
that processes online tests. The basic question is, "Should I implement
the SingleThreadModel on the servlet since many students maybe
trying to submit their tests symultaneously for processing?" The servlet
does contain three instance variables which perhaps need to remain as such
so that an inner class and statements in the doPost(...) method
have access to them. Please advise if changes are necessary.

Servlet Structure and Business Logic:

The servlet contains two inner classes named Answer and XMLAnswerHandler.
A backend database contains the answers
to the tests in the form of xml markup. To process an online test,
in the doPost(...) method, I read in the xml data from the database
using the XMLAnswerHandler class which implements
org.xml.sax.helpers.DefaultHandler. XMLAnswerHandler
is used to create an instance variable ArrayList named "answers" to
contain multiple instances of class Answer. Class Answer contains
an item identifier and the actual answers to a particular test
question (item). Also, in the doPost(...) method I load up another
instance variable ArrayList named "studentAnswers" again with
multiple instances of class Answer. I then, compare the answers
given by the student with the answers in the answers ArrayList to
determine a final score.