Program
Internal Operation
Initialization of servlet configuration
-
EmailServlet gets initial parameters from web.xml and do necessary
initializations
-
EmailServlet sets up a TextProcessor, a DeleteFileThread, and a
Log
-
EmailServlet starts the thread
Login
-
EmailServlet receives a request from the voice browser
-
EmailServlet gets the user information and create a temporary directory
where audio files will be stored
-
Since it's the first request, the action parameter is null
-
EmailServlet forwards the request to login.jsp
-
login.jsp generates a VoiceXML page that asks the user to enter user ID
and PIN.
-
The voice browser renders the voiceXML page, and the user hears the audio
dialog.
-
The voice browser sends a login request to EmailServlet with these parameters:
action, login, and pin
-
EmailServlet calls doLogin.
-
EmailServlet accesses the database to verify the user login and pin.
-
If login correct, get user's account and address book, sets four session
attributes (old and new message ArrayLists, and old and new message numbers),
and sorts new messages. Forwards the request to menu.jsp
-
If login incorrect, forwards request to error_auth.jsp
Email By Phone Options
-
menu.jsp looks up session attributes: oldmsgnum and newmsgnum
-
If there are new messages (newmsgnum>0), options are: read new messages,
read old messages, or compose a new message
-
Else if there are old messages, options are: read old messages, or compose
a new message
-
Else, compose a new message is the option
-
The voice browser sends a different request and parameters to EmailServlet,
depending on the user's choice
-
read new messages- parameters: msgnum = 1, readnew = true, action = disphdr
-
read old messages- parameters: msgnum = 1, readnew = false, action = disphdr
-
compose a message- parameters: msgnum = 1, readnew = true, action = compose
Reading a message header
-
EmailServlet receives a disphdr request. Calls doDisplayHeader
-
EmailServlet gets old/new messages, depending on the parameter readnew
-
EmailServlet accesses user's email folder and confirms that the parameter
msgnum is a valid message number
-
If invalid, sets the header to "No more messages"
-
If valid, gets the specific message and create a message header string
-
EmailSevlet forwards the request to disphdr.jsp, passing the msgnum and
header
-
disphdr.jsp reads out the message header
-
disphdr.jsp reads out the choices if the user says "help"
-
If session attribute readnew = true, choices are : Listen , Reply, Delete,
Forward, Previous, Next, Jump, Compose, and Switch to old messages
-
Else, the choices are : Listen , Reply, Delete, Forward, Previous, Next,
Jump, Compose, and Switch to new messages
-
The voice browser sends a different request and parameters to EmailServlet,
depending on the user's choice
-
Listen - parameters: msgnum (unchanged), readnew (unchanged), action =
dispmsg
-
Reply- parameters: msgnum (unchanged), readnew (unchanged), action = record
-
Delete- parameters: msgnum (unchanged), readnew (unchanged), action = delete
-
Forward- parameters: msgnum (unchanged), readnew (unchanged), action =
forward
-
Previous- parameters: msgnum--, readnew (unchanged), action = disphdr
-
Next- parameters: msgnum++, readnew (unchanged), action = disphdr
-
Jump
-
Reads out the number of old/new messages the user has and asks the message
number the user wants to jump to.
-
parameters: msgnum specified by the user, readnew (unchanged), action
= chkmsg
-
EmailServlet receives a chkmsg request. Calls doCheckMessage and verifies
that the msgnum passed is valid.
-
If valid, calls doDisplayHeader.(sec. ) Otherwise, forward the request
to error_msgnum.jsp
-
Compose- parameters: msgnum (unchanged), readnew (unchanged), action =
compose
-
Switch to old messages- parameters: msgnum = 1, readnew = false, action
= disphdr
-
Switch to new messages- parameters: msgnum = 1, readnew = true, action
= disphdr
Reading a message
-
EmailServlet receives a dispmsg request. Calls doDisplayMessage.
-
EmailServlet gets old/new messages, depending on the parameter readnew
-
EmailServlet accesses user's email folder and confirms that the parameter
msgnum is a valid message number
-
If invalid, sets the message body to "No more messages"
-
If valid, gets the specific message and create a message body string as
follows: Check each Part of the message. If a part is a text/plain, simply
concatenate the part to the message body string. Else if the part is a
supported audio file, save the file temporarily and add the URL to the
file in audioURLs vector. Else, concatenate the part's content type and
file name to the message body string.
-
EmailServlet filters the message body through the text processor.
-
EmailSevlet forwards the request to dispmsg.jsp, passing the msgnum, msgbody,
and audioURLs
-
dispmsg.jsp reads out the message body and plays any audio attachment the
message may have
-
dispmsg.jsp reads out the choices if the user says "help"
-
If session attribute readnew = true, choices are : Listen, Reply, Delete,
Forward, Previous, Next, Jump, Compose, and Switch to old messages
-
Else, the choices are : Listen , Reply, Delete, Forward, Previous, Next,
Jump, Compose, and Switch to new messages
-
The voice browser sends a different request and parameters to EmailServlet,
depending on the user's choice
-
Listen - parameters: msgnum (unchanged), readnew (unchanged), action =
dispmsg
-
Reply- parameters: msgnum (unchanged), readnew (unchanged), action = record
-
Delete- parameters: msgnum (unchanged), readnew (unchanged), action = delete
-
Forward- parameters: msgnum (unchanged), readnew (unchanged), action =
forward
-
Previous- parameters: msgnum--, readnew (unchanged), action = disphdr
-
Next- parameters: msgnum++, readnew (unchanged), action = disphdr
-
Jump
-
Reads out the number of old/new messages the user has and asks the message
number the user wants to jump to.
-
parameters: msgnum specified by the user, readnew (unchanged), action
= chkmsg
-
EmailServlet receives a chkmsg request. Calls doCheckMessage and verifies
that the msgnum passed is valid.
-
If valid, calls doDisplayHeader.(sec. ) Otherwise, forward the request
to error_msgnum.jsp
-
Compose- parameters: msgnum (unchanged), readnew (unchanged), action =
compose
-
Switch to old messages- parameters: msgnum = 1, readnew = false, action
= disphdr
-
Switch to new messages- parameters: msgnum = 1, readnew = true, action
= disphdr
Deleting a message
-
EmailServlet receives a delete request and calls doDeleteMessage
-
EmailServlet gets old/new message ArrayList, depending on the parameter
readnew
-
EmailServlet gets the specific message from user's folder and marks it
DELETED
-
EmailServlet removes the specific message from the ArrayList
-
EmailServlet expunges the folder.
-
EmailServlet forwards the request to delete.jsp, passing the msgnum.
-
delete.jsp informs the user about successful deletion of the message and
sends a request to EmailServlet with parameters: action = disphdr,
msgnum (unchanged)
Replying to a message
-
EmailServlet receives a reply request and calls doReply
-
EmailServlet creates a new message and attaches the recorded voice message
and the original message
-
EmailServlet sends the message
-
EmailServlet forwards the request to msgsent.jsp, passing msgnum.
-
msgsent.jsp informs the user that the message was sent successfully and
sends a request to EmailServlet with parameters: action = disphdr,
msgnum (unchanged)
Forwarding a message
-
EmailServlet receives a forwardmsg request and calls doForwardMsg
-
EmailServlet creates a new message and attaches the recorded voice message
and the original message
-
EmailServlet sends the message
-
EmailServlet forwards the request to msgsent.jsp, passing msgnum.
-
msgsent.jsp informs the user that the message was sent successfully and
sends a request to EmailServlet with parameters: action = disphdr,
msgnum (unchanged)
Composing to a message
-
EmailServlet receives a sendmsg request and calls doSendMessage
-
EmailServlet creates a new message and attaches the recorded voice message
-
EmailServlet sends the message
-
EmailServlet forwards the request to msgsent.jsp, passing msgnum.
-
msgsent.jsp informs the user that the message was sent successfully and
sends a request to EmailServlet with parameters: action = disphdr,
msgnum (unchanged)
Recording a message
-
EmailServlet receives a record, compose, or forward request and calls doRecord,
doCompose or doForward, respectively
-
doRecord simply forwards the request to recmsg.jsp, passing msgnum. doCompose
forwards the request to composemsg.jsp, passing msgnum, and addbk. doForward
forwards the request to foward.jsp, passing the same attributes as doCompose.
-
recmsg.jsp records the user's message and sends a reply request to EmailServlet
with parameters: actions = reply, and msgnum (unchanged) composemsg.jsp
and forward.jsp performs the same operations: Asks the user who he wants
to send the message to, records his message, and sends a sendmsg (or forwardmsg)
request to EmailServlet with parameters: action = sendmsg (or forwardmsg),
email address of the recipient, recorded file name, and msgnum
Sorting messages
-
At login, new messages (if any) are sorted by calling doSort
-
A MessageCompartor is used to sort the new messages according to message's
overall priority
-
MessageCompartor takes two objects, cast them to Message objects, and compares
the overall priority of the messages.
-
A message is considered to have a high priority if it a) is sent to the
user only and not to some mailing list; b) contains any audio attachment(s);
or c) is marked as a high priority mail
-
MessageComparator return -1 is the first argument should precede the second
argument in the ArrayList, 1 if the first should succeed the second, and
0 if indifferent
Email text processing
-
A TextProcessor and dformat method in EmailServlet makes the email body
text more speech synthesis friendly
-
TextProcessor attempts to eliminate email signatures and ascii art. Also
tries to handle replied/forwarded messages by removing the
>'s and replacing it with "Original Message Follows:" and ending the
forwarded message section with "End of Original Message."
-
dformat method converts the received date of a message from a format "dow
mon dd hh:mm:ss zzz yyyy" to a more readable format: "EEE MMM dd HH:mm:ss
zzz yyyy"
Deleting audio files
-
Periodically deletes the files and subdirectories in a specified
directory older than one hour old. The default sleep time is 3600000 secs.
Logging
-
Logs messages to appropriate streams specified by a properties file. If
an appropriate file stream cannot be found, System.out is used. There are
five different level of logging.
Error handling
-
When an error occurs while EmailServlet processes a request, it is handled
by forwarding the request to an appropriate jsp.
-
error_auth.jsp handles incorrect login by asking the user ID and PIN and
sending a login request to EmailServlet again
-
error_msgnum.jsp handles incorrect message number input and asks for a
different message number
-
error.jsp handles any other errors by reading out the error message EmailServlet
passes to it