6 Set up with the indicating and adjustment module
6.3 Parameter adjustment
Aquí tenemos unas cuantas imágenes de la ejecución del ejemplo, con su correspondiente código fuente. El punto de entrada es index.html.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> <HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html;CHARSET=iso-8859-1"> <TITLE>JavaMail</TITLE>
</HEAD>
<BODY BGCOLOR="#CCCCFF">
<FORM ACTION="login" METHOD=POST ENCTYPE="application/x-www-form-urlencoded"> <P ALIGN="CENTER"><B>Welcome to JavaMail</B></P>
<CENTER> <P>
<TABLE BORDER="0" WIDTH="100%"> <TR>
<TD WIDTH="40%">
<P ALIGN="RIGHT">IMAP Hostname: </TD>
<TD WIDTH="60%"><INPUT TYPE="TEXT" NAME="hostname" SIZE="25"></TD> </TR>
<TR>
<TD WIDTH="40%">
<P ALIGN="RIGHT">Username: </TD>
<TD WIDTH="60%"><INPUT TYPE="TEXT" NAME="username" SIZE="25"></TD> </TR>
<TR>
<TD WIDTH="40%">
<P ALIGN="RIGHT">Password: </TD>
<TD WIDTH="60%"><INPUT TYPE="PASSWORD" NAME="password" SIZE="25"></TD> </TR>
</TABLE>
<INPUT TYPE="SUBMIT" VALUE="Login">
<INPUT TYPE="RESET" NAME="Reset" VALUE="Reset"></P> </CENTER>
<P><B><I>Features:</I></B></P> <UL>
<LI>HTML access to your IMAP mailbox
<LI>Proxy-able anywhere HTTP can be proxied <LI>Easy to use
<LI>Uses web browser's content handling capabilities </UL>
<P><B><I>Limitations:</I></B></P> <UL>
<LI>Only INBOX support (no user folders)
<LI>Can't delete, copy, move, print, save, forward, reply to, search in messages but it could be done
<LI>Doesn't check for new messages (have to log out and log back it) </UL> <P> <HR ALIGN="CENTER"> </P> </FORM> </BODY> </HTML>
Un login con éxito nos lleva al inbox. Si el login falla, se muestra la página de error. Entonces el usuario tiene una opción para ver los detalles del error.
<%@ page language="java" import="MailUserBean" %> <%@ page errorPage="errorpage.jsp" %> <%@ taglib uri="http://java.sun.com/products/javamail/demo/webapp" prefix="javamail" %> <html> <head> <title>JavaMail messageheaders</title> </head> <body bgcolor="#ccccff"><hr>
<center><font face="Arial,Helvetica" font size="+3"> <b>Folder INBOX</b></font></center><p>
<font face="Arial,Helvetica" font size="+3"> <b><a href="logout">Logout</a>
<a href="compose" target="compose">Compose</a> </b></font>
<hr>
<table cellpadding=1 cellspacing=1 width="100%" border=1> <tr>
<td width="25%" bgcolor="ffffcc">
<font face="Arial,Helvetica" font size="+1"> <b>Sender</b></font></td>
<td width="15%" bgcolor="ffffcc">
<font face="Arial,Helvetica" font size="+1"> <b>Date</b></font></td>
<td bgcolor="ffffcc">
<font face="Arial,Helvetica" font size="+1"> <b>Subject</b></font></td> </tr> <javamail:listmessages id="parteV_msginfo" folder="folder"> <%-- from --%> <tr valign=middle> <td width="25%" bgcolor="ffffff"> <font face="Arial,Helvetica"> <% if (msginfo.hasFrom()) { %> <%= msginfo.getFrom() %> </font> <% } else { %>
<font face="Arial,Helvetica,sans-serif"> Unknown
<% } %> </font></td> <%-- date --%>
<td nowrap width="15%" bgcolor="ffffff"> <font face="Arial,Helvetica">
<%= msginfo.getDate() %> </font></td>
<%-- subject & link --%> <td bgcolor="ffffff">
<font face="Arial,Helvetica">
<a href="messagecontent?message=<%= msginfo.getNum() %>"> <% if (msginfo.hasSubject()) { %> <%= msginfo.getSubject() %> <% } else { %> <i>No Subject</i> <% } %> </a> </font></td> </tr> </javamail:listmessages> </table> </body> </html> <%@ page isErrorPage="true" %> <html> <head> <title>JavaMail errorpage</title> </head> <body bgcolor="white">
<form ACTION="errordetails" METHOD=POST>
<% session.putValue("details", exception.toString()); %>
<h2>An error occured while attempting to perform the operation you requested. </h2>
<input type="submit" name="Error Details" value="Error Details"> </body>
<%@ page isErrorPage="true" %> <html> <head> <title>JavaMail errordetails</title> </head> <body bgcolor="white"> <%= session.getValue("details") %> </body> </html>
<%@ page language="java" %> <%@ page errorPage="errorpage.jsp" %> <html> <head> <title>JavaMail compose</title> </head> <body bgcolor="#ccccff">
<form ACTION="send" METHOD=POST>
<input type="hidden" name="send" value="send"> <p align="center">
<b><font size="4" face="Verdana, Arial, Helvetica"> JavaMail Compose Message</font></b>
<p>
<table border="0" width="100%"> <tr>
<td width="16%" height="22"> <p align="right">
<b><font face="Verdana, Arial, Helvetica">To:</font></b></td> <td width="84%" height="22">
<% if (request.getParameter("to") != null) { %>
<input type="text" name="to" value="<%= request.getParameter("to") %>" size="30"> <% } else { %>
<input type="text" name="to" size="30"> <% } %>
<font size="1" face="Verdana, Arial, Helvetica"> (separate addresses with commas)</font></td></tr> <tr>
<td width="16%"><p align="right">
<b><font face="Verdana, Arial, Helvetica">From:</font></b></td> <td width="84%">
<input type="text" name="from" size="30"> <font size="1" face="Verdana, Arial, Helvetica"> (separate addresses with commas)</font></td></tr> <tr>
<td width="16%"><p align="right">
<b><font face="Verdana, Arial, Helvetica">Subject:</font></b></td> <td width="84%">
<input type="text" name="subject" size="55"></td></tr> <tr>
<td width="16%"> </td>
<td width="84%"><textarea name="text" rows="15" cols="53"></textarea></td></tr> <tr>
<td width="16%" height="32"> </td> <td width="84%" height="32">
<input type="submit" name="Send" value="Send">
<input type="reset" name="Reset" value="Reset"></td></tr> </table>
</form> </body> </html>
<%@ page language="java" import="MailUserBean" %> <%@ page errorPage="errorpage.jsp" %>
<jsp:useBean id="parteV_mailuser" scope="session" class="MailUserBean" /> <html> <head> <title>JavaMail logout</title> </head> <% mailuser.logout(); %> <body>
<h2>Logged out OK</h2><a href=index.html>click here to login</a> </body>
</html>
EWA está compuesto por un documento HTML y varios documentos web (servlets y JSP y etiquetas persnalizadas). a parte de estos, tiene dos directorios:META-INF y