caucho
Resin
FAQ
Reference Guide
Demo
Tutorial

JSP page
Config
URLs
Database Forms
XTP Copy
Hello Tag
Vary Filter
HardCore
Mailing Forms
Beans
Cache
XSL Filter
run-at
jndi app config
 Mailing Forms

HardCore
Tutorial
Beans

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");


HardCore
Tutorial
Beans
Copyright © 1998-2002 Caucho Technology, Inc. All rights reserved.
Resin® is a registered trademark, and HardCoretm and Quercustm are trademarks of Caucho Technology, Inc.