Trivia servlet 1.3

    It is a Java servlet allows you to implement Trivia games or any test suite on your mobile phone with WAP support. Servlet reads XML-data file with the description of your test and generates on the fly an appropriate code for WML.

How to use it:

a) copy triviaPackage.jar into your WEB-INF/lib directory.

b) define servlet in your web.xml file.


define a mapping:


You can use Trivia in two forms.

a) pass configuration file as a parameter. E.g.:


b) define your XML file as an initial parameter for servlet (parameter name is config):


and use servlet in this form:


XML file must define the following elements:

Trivia => (title, timeout, +question)

title - defines title for your game/test
timeout - defines timeout for individual questions (in seconds).

question => (ask, +option)

ask - defines the question
option - defines an alternative for this question. At least one of defined options must have an attribute correct with the value true or yes. This attribute marks the correct answer.

For example:



<ask>What is a Java?</ask>
<option correct="yes">Programming language</option>
<option>Yet another buzzword</option>

<ask>What is a Coldbeans?</ask>
<option>Cold tea</option>
<option correct="true">Software start-up</option>
<option>Yet another buzzword</option>



1. Servlet uses JAXP for parsing XML files.

2. Data file can be saved anywhere on your server. E.g. if you are using Trivia?data.xml we assume this file (data.xml) is saved under the root (docBase) directory of your servletrunner. But you can of course always use the full path for setting data file location. E.g. some like this: Trivia?/home/users/my_file (or Trivia?c:\users\my_file)

    For downloading: 

    Servlet:  triviaPackage.jar   
    Sample of xml file:  trivia.xml

  © Coldbeans     Comments?

See also JSOS - the largest collection of servlets and filters.