Mailing Forms
Resin 3.0

Features
Installation
Configuration
Web Applications
IOC/AOP
Resources
JSP
Quercus
Servlets and Filters
Databases
Admin (JMX)
CMP
EJB
Amber
EJB 3.0
Security
XML and XSLT
XTP
JMS
Performance
Protocols
Third-party
Troubleshooting/FAQ

Introduction
JSP Compilation
Reference
Tutorials
Articles
FAQ

JSP Page Creation
Request
Topics
Tag Libraries

Mailing form results
Java beans
Topics
Topics
Java beans

Mailing Forms

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


Topics
Topics
Java beans
Copyright © 1998-2006 Caucho Technology, Inc. All rights reserved.
Resin® is a registered trademark, and HardCoretm and Quercustm are trademarks of Caucho Technology, Inc.