Suppose this scenario. A lecturer dedices to provide several quizzes periodically for students. Because each quiz may not have the same number of questions, the lecturer have to use the instructor.jsp web page to edit a specific quiz every time, which can include a lot of single and multiple choice questions. Once the lecturer had done, the content of this quiz must form another JSP file automatically, which name should be like "quiz+system time.jsp" so as to distinguish from each other.
My question is whether I can only use JSP technology to accomplish the whole thing above and how I can do it. Please give me some advice about the general steps to do so.
A jsp is just a text file so, as long as your app is running as an exploded file system, there is no reason that you couldn't use the classes in java.io.* to write whatever text you like to a file within the webapp.
Of course, you could also have one test page that get's all of its questions from a database. This would probably be a lot easier to track and maintain than a bunch of dynamically created JSPs.
I really appreciate your advice. According your instruction, now I come up with a new idea. In my webapp, I decide to create one instructor.jsp file for the lecturer. Every time when he/she presses the submit button to upload the quiz, its content, including the system time and the later generating quiz file name, will be stored as a record in a database's table. At the time the students need to do this quiz, they will first read from the table to create the quiz JSP file, like quiz09232006.jsp, and forward to it, then test it.
William, in your reply
Much better to come up with a more general solution that does not need to recompile a JSP for each quiz. How about a custom tag or JavaBean that reads a simple script that defines the quiz?
Do you mean the reading table section in the quiz09232006.jsp file should use custom tag or JavaBean? The quiz results should be graded usually. Now I plan to use two steps to implement it. First, using application attribute to store the correct answer in the instructor.jsp file. Second, comparing each student's answer with the attribute's value and store the result in an other database table. Is it right? Because the number of questions in each quiz are not equal, the instructor.jsp could not be instructor.html. Right? Correct me, if I am wrong.
Best Regards, Ailsa Cape
Author and all-around good cowpoke
Joined: Mar 22, 2000
Do you mean the reading table section in the quiz09232006.jsp file should use custom tag or JavaBean?
No, I mean that quiz.jsp should be able to read a session parameter or request parameter to find out that script "09232006" should be read by a JavaBean helper class and used to write the quiz questions portion of the page sent to the student. No unique JSP per quiz, only a generic quiz formatting JSP that can read a script to get the parts that are unique to a particular quiz. It seems to me you are trying to make JSP do everything - a sure recipe for a hard to maintain application. Bill