|
resin
example
$resin/java_tut/mail_form.xtp
A convenient way of gathering form data is simply to mail the
form results to a mailbox
A convenient way of gathering form data is simply to mail the
form results to a mailbox. Resin supports sending mail with
it's Virtual File System.
A convenient way of gathering form data is simply to mail the form
results to a mailbox. Mail is the most effective push technology.
Sending mail with Resin is just like writing to a file. Resin
recycles APIs to reduce information pollution. Its VFS (virtual file
system) extends and simplifies java.io. Sending mail is just like
writing to a file. Resin's Path class is like File and
its WriteStream is a combination of OutputStream and
PrintWriter.
<%@ page language=java %>
<%@ page import='com.caucho.vfs.*' %>
<%@ page import='java.util.*' %>
<%
Path mail;
mail = Vfs.lookup("mailto:survey?subject='Colors'");
WriteStream os = mail.openWrite();
Enumeration e = request.getParameterNames();
while (e.hasMoreElements()) {
String key = (String) e.nextElement();
String value = request.getParameter(key);
os.println(key + ": " + value);
}
os.close();
%>
<h1>Thank you for your response.</h1>
name: Kermit the Frog
color: green
The example mails results to a user named survey on the web
server. The subject of the mail is Colors. Scripts can add
their own mail headers, including cc, bcc, and even
from. To add multiple headers, separate them by
&.
Vfs.lookup("mailto:you?subject=test&bcc=me");
Copyright (c) 1998-2009 Caucho Technology, Inc. All rights reserved. caucho® ,
resin® and
quercus®
are registered trademarks of Caucho Technology, Inc.
|