The servlet is a simple implementation that behaves based on the value of an 'operation' parameter (op) that is passed as part of the request.
private static final String PARAM_OP = "op";
The op
operation can take one of the values: categories, byCategory, byAuthor, addBookForm
, and addBook
.
The categories
operation requests a listing of the currently registered categories.
private static final String OP_CATEGORIES = "categories";
The byCategory
and byAuthor
operations request a listing of the books in a given category and by a given author, respectively.
private static final String OP_BYCATEGORY = "byCategory"; private static final String OP_BYAUTHOR = "byAuthor";
Their category
and author
parameters are passed using:
private static final String PARAM_CATEGORY = "category"; private static final String PARAM_AUTHOR = "author";
The addBookForm
operation requests the display of the form for adding a book:
private static final String OP_ADDBOOKFORM = "addBookForm";
It will pass the parameters of the book using the category
and author
keys, as defined previously along with the isbn, title
, and rating:
private static final String PARAM_ISBN = "isbn"; private static final String PARAM_TITLE = "title"; private static final String PARAM_RATING = "rating";
The parameters for adding a book are passed to the addBook
operation as follows:
private static final String OP_ADDBOOK = "addBook";
And last, but not least, the authentication form is displayed with the loginForm
operation and the authentication request using the login
operation, along with the user
and pass
parameters.
private static final String OP_LOGINFORM = "loginForm"; private static final String OP_LOGIN = "login"; private static final String PARAM_USER = "user"; private static final String PARAM_PASS = "pass";
Those constants will be used in the code and embedded in the generated HTML.