vy/pathlopedia — Issue #3: Temporary UserAdd, UserLogin, and UserLogout Views
Author: vy
Created: 2011-11-14 12:56:00+00:00
State: open

Make a simple _user sign-up_ display in the `index.jsp`. (You are welcome to use the widgets and CSS classes used in `index.html` I provided offline.) Send the request to `UserAddServlet` with input parameters `type`, `name`, and `email`. Before sending the user input to the server side, validate the fields as follows.
* See `User.Type` for a list of available `type`s. (Pay attention that enum-to-database mappings are case sensitive.)
* Validate `name` according to `NAME_MIN_LENGTH` and `NAME_MAX_LENGTH` constants defined in `DatastorePortal`.
* Likewise, use `MAIL_MAX_LENGTH` to validate `email` field.

In case of **success**,
1. Store returned `id` in `user_id` cookie.
2. Store user type, name, and e-mail in `user_type`, `user_name`, and `user_email` cookies, respectively.
3. Replace the _user sign-up_ display with the _user info_ display. (For an example, see `index.html` I provided offline.) Don't forget to place a _sign-out_ button!

In case of **failure**, display the error message to the user.

When _sign-out_ button is pressed,
1. Redirect request to `UserLogoutServlet`,
2. Clear user/session cookies,
3. Replace _user info_ display with a _user sign-in_ display.

_User sign-in_ display is left to your imagination. Pay attention that we are expecting user emails to be unique. Also, I would strongly recommend to use the `user_email` cookie as a default value for the `email` field in the _user sign-in_ display.