Java Reference
In-Depth Information
<html><head><title>UbiMail -
<%
#
user%>'s details</title></head>
<body><h1>UbiMail</h1>
Hello <%
#
user%>.
<hr>
<h2>User details</h2>
Please provide the details for your POP server.
<form method
#
"POST" action
#
"main.jsp">
<table>
<tr><td>POP server:
<td><input type
#
text name
#
"popServer" size
#
30>
<tr><td>POP user:
<td><input type
#
text name
#
"popUser" size
#
30>
<tr><td>POP password:
<td><input type
#
password name
#
"popPass" size
#
30>
<tr><td colspan
#
2 align
#
center>
<input type
#
submit value
#
"Enter">
</table>
</form>
<hr>
<i>UbiMail - Ubiquitous e-mail system</i>
</body></html>
The core of the application is
main.jsp
. If this is the first invocation of this
JSP in the session, it starts a new mail session, connects to the server and
opens the default message folder. Otherwise it recovers the mail objects
stored in the session attributes. This page builds a table and for each
message in the folder adds a row containing the subject, the sender and the
date of the message. Each message has a number that is a link to the JSP that
shows the contents; the URL has an additional
?index
#
n
where
n
is the
number of the message. This is the standard way of passing parameters. To
make reading a long list of messages easier the rows alternate a light blue and
a pink background.
<%@
page contentType
#
"text/html" language
#
"java"
%>
<%@
page
import
#
"javax.mail.*, java.util.Properties,
java.util.Enumeration"
%>
<% if
(session.isNew()){
response.sendRedirect("index.html");
return
;
}
String user
#
(String) session.getAttribute("user");
Folder folder
#
(Folder) session.getAttribute("folder");
%>
<html><head><title>
UbiMail -
<%
#
user
%>
's mailbox
</title></head>
<body>