|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.servlet.GenericServlet | +--javax.servlet.http.HttpServlet | +--VocTrainer
VocTrainer is a servlet. It is designed to run with the vq-server on Windows platforms. It may also run with other servers on different platforms as well, but this has not been tested, yet.
VocTrainer is a (as one can guess from the name) vobable trainer. For more detailed information on the performance and abilities of this software please read the (TeX, pdf) documentation that goes with this distribution. The following text describes the general concept and the implementation of this servlet.
The two commonly used methods in a servlet are the doPost(..) and doGet(..) methods. We combined these two methods to a simple doMain(..) methods for we do not really need to differ between post and get. The doMain method handles the user administration stuff that is needed for most servlets. If the servlet is called the first time by a user there is no event specified and no HTML page supplied. In this case the login HTML template is shown. The other actions that are provided by this method are deleting a user and generating a new account. All other events are delegated to the handleEvent(...) method of this class.
There is no direct access to the database that holds the information of the users. All database access is shielded by either the UserAdministration class (for user information) or VocableAdministration class (for vocable information). If you are interested in the database connection and handling please read the documentation of these two classes.
To be more flexible in displaying HTML pages we use HTML template files. A template file is a file which contains most of the information but also leaves some gaps to fill in case dependend data, such a a nickname or the secure identity of a user. The template files are handled using the HTMLTemplate class. To understand the following concepts you should be familiar with the HTMTemplate class and the basic methods of the UserAdministration.
The base concept is that there is a HTML form which at least has three fields:
If there is no event specified then the login HTML template is shown by default. If there is a event specified that is not handled by the servlet an error HTML template is shown. In all other cases the code block for the eventhandling is responsible for the following pages displayed. Any uncaught Exception will also force to display the error page.
The steps in the eventhandling:
Dear subclassers:
It' s possible to subclass this servlet to take advantage of the already build login procedure. Please ensure when you plan to do so that you overwrite the handleEventMethod of this class. In this case do call the the method before you do your own eventhandling. A returnvalue null means that the event was not handled. Any other returnvalue should be taken as result and be returned! Please read the description of the method carefully. The second important thing is that you do use the same user fields in your database as they are used in the sample database distributed with this package. See the UserAdministration class for more detailed information of the database structure.
DO NOT USE THE FOLLOWING EVENTS:
Field Summary | |
protected java.util.Locale |
locale
the locale that is used to display the templates and messages. |
protected java.util.ResourceBundle |
rb
the ResourceBundle for this servlet. |
protected ServletParameters |
servletParam
holds the servlet parameters of the configuration, e.g. |
protected HTMLTemplate |
template
holds the variables and HTML template files. |
protected SimpleUserAdministration |
userAdmin
user administration |
Constructor Summary | |
VocTrainer()
|
Method Summary | |
void |
doGet(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Delegates to doMain(...) |
void |
doPost(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Delegates to doMain(...) |
protected java.lang.String |
handleEvents(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
User user,
java.lang.String event)
Handles all events of the actual servlet implementation except the user administration and login. |
void |
init(javax.servlet.ServletConfig in_conf)
initializes this servlet |
Methods inherited from class javax.servlet.http.HttpServlet |
doDelete, doOptions, doPut, doTrace, getLastModified, service, service |
Methods inherited from class javax.servlet.GenericServlet |
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, init, log, log |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected SimpleUserAdministration userAdmin
protected ServletParameters servletParam
protected HTMLTemplate template
protected java.util.Locale locale
protected java.util.ResourceBundle rb
Constructor Detail |
public VocTrainer()
Method Detail |
public void init(javax.servlet.ServletConfig in_conf) throws javax.servlet.ServletException
init
in class javax.servlet.GenericServlet
public void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException
doGet
in class javax.servlet.http.HttpServlet
public void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException
doPost
in class javax.servlet.http.HttpServlet
protected java.lang.String handleEvents(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, User user, java.lang.String event) throws java.lang.Exception
request
- The request from doMain().response
- The response from doMain().user
- The authorized user.event
- The event that should be handled.
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |