Skip Headers

Oracle Application Server Containers for J2EE JSP Tag Libraries and Utilities Reference
10g (9.0.4)

Part Number B10319-01
Go To Documentation Library
Home
Go To Table Of Contents
Contents
Go To Index
Index

Go to previous page Go to next page

8
File Access and Mail Beans and Tags

This chapter covers OC4J tags and JavaBeans for file access (uploading and downloading) and for e-mail. The e-mail tag and JavaBean make use of the file access functionality for attachments. The chapter is organized as follows:

File-Access JavaBeans and Tags

OC4J provides a standards-compliant tag library and JavaBeans that add convenient file upload and file download functionality for JSP pages and servlets. Files can be uploaded to or downloaded from a file system or database.

The following sections document the file-access tags and beans:


Note:

In Oracle Application Server, the file-access JavaBeans and tags require the OC4J environment; JServ is not supported.


Overview of OC4J File-Access Functionality

Developers have the option of using either custom tags or JavaBeans to program applications that allow users to upload or download files. In either case, the application is presumably programmed so that users specify through the browser where files come from on the client system for uploading or where they go to on the client system for downloading. For JSP pages for uploading, OC4J supplies a convenience tag, httpUploadForm, to create a form to use in specifying where the files come from.

For processing an upload, including specifying the destination file system or database location, use the HttpUploadBean JavaBean or the httpUpload tag. For processing a download, including specifying the source file system or database location, use HttpDownloadBean or the httpDownload tag. The beans extend HttpFileAccessBean, which is not intended for public use. All of the beans are in the oracle.jsp.webutil.fileaccess package.

Overview of File Uploading

For user specification in a JSP page of where uploaded files will come from, you can use the httpUploadForm tag to create a form. This tag lets users select the files for uploading and creates the necessary multipart HTTP request. You also have the option of using a standard HTML form to create the request.

Use the HttpUploadBean JavaBean or the httpUpload tag to receive and process the multipart form-encoded data stream and write the files to the appropriate location, either in the file system or a database. There is functionality to let you decide whether previous data will be overwritten if the target file or database row already exists.


Note:

The maximum file size for any upload is 2 GB.


File System Destination

If the destination is in a file system, you must provide a properties file that designates a base directory. The properties file must be named fileaccess.properties, must be located in the /WEB-INF directory of your application, and must have a fileaccess.basedir entry that indicates an absolute directory path. Here is an example:

fileaccess.basedir=/tmp


Note:

On a Windows system, you must still use a forward-slash, not a back-slash, for the directory path:

fileaccess.basedir=c:/tmp

Furthermore, the specified drive (C: in this case) must be the same drive on which OC4J is installed.


There should be subdirectories as appropriate under the base directory, such as a subdirectory for each authorized user. Destination subdirectories under the base directory must be specified through an attribute of the upload bean or tag. All directories and subdirectories must already exist and be writable; they cannot be created or made writable through OC4J functionality.

Database Destination

If the destination is in a database, you can optionally use a default table, fileaccess, that you create through the supplied fileaccess.sql script, or you can use any other previously existing table containing the required column types. In either case, you must provide a connection to the database, as an instance of either oracle.jsp.dbutil.ConnBean or the standard java.sql.Connection. You can provide a ConnBean instance explicitly, or in a JSP page you also have the option of providing it implicitly as a result of nesting the httpUpload tag inside a dbOpen tag. (For information about the ConnBean JavaBean and dbOpen tag, see Chapter 4, "Data-Access JavaBeans and Tags".)


Note:

The java.sql.Connection type is currently supported for the file-access beans only, not the tags.


You are also required to specify a destination through an attribute of the upload bean or tag. The destination is simply a Java string value that will be placed in the prefix column of the database table. The prefix is equivalent to a file system path.

File data is written to a database as either a BLOB or a CLOB. You can specify which through an upload bean or tag attribute.

If you do not use the default fileaccess table, you must use attributes of the upload bean or tag to specify the database table name and the names of the columns that will contain the file data, the file prefix, and the file name. Any other table you use must adhere to the pattern of fileaccess, as follows:


Notes:

  • When you use a ConnBean instance, the connection will be closed automatically at the end of the scope designated in the jsp:useBean tag that invokes it. There is no such functionality for a Connection instance.

  • ConnBean uses and requires the JspScopeListener interface. See "JSP Event-Handling with JspScopeListener" for information about that utility.


Security Considerations for Uploading

For uploading to a database, the database table does not have a column to indicate a particular authorized user for any given file. Therefore, without precaution, each user can see files that were uploaded by other users, without having to know the file prefixes. To prevent this, you can prepend an appropriate user name to each prefix.

Overview of File Downloading

Use the HttpDownloadBean JavaBean or the httpDownload tag as follows:

There is also functionality to specify whether you want recursive downloading, where files in subdirectories or with additional database prefix information will also be available for download. For database downloading, a prefix is equivalent to a file system path and can be used to group files into a hierarchy. As an example of recursive downloading from a database, assume you have specified /user as the prefix. Recursive downloading would find matches for files with any prefixes starting with "/user", such as "/user/bill" and "/user/mary", and also such as "/user1", "/user2", "/user1/tom", and "/user2/susan".

For downloading files from a file system, utilize the mechanism described in "Overview of File Uploading". Use the fileaccess.properties file to specify a base directory and use attributes in the download bean or tag to specify the rest of the file path.

For downloading files from a database, as with uploading files to a database, you must provide an instance of oracle.jsp.dbutil.ConnBean or java.sql.Connection. In addition, if you are not using the default fileaccess table (that you can create using the supplied fileaccess.sql script), you must provide all the necessary information about the database table and columns. Specify this information through attributes of the download bean or tag.

The actual downloading of the files is accomplished by DownloadServlet, supplied with OC4J. In using the download tag, specify the path of this servlet through a tag attribute. For a file system source, hyperlinks are automatically created to the servlet so that the user can select a link for each file in order to download the file. For a database source, the servlet will fetch the selected CLOB or BLOB data that forms the file contents. (See "The Download Servlet".)

Security Considerations for Downloading

For downloading, consider limiting the users' ability to see what is in the source (server-side) file system or database. Without precaution, the following scenarios are possible:

If this is of concern, you can consider protective measures such as the following:

File Upload and Download JavaBean and Class Descriptions

This section describes attributes and methods of the file upload and download JavaBeans provided with OC4J: HttpUploadBean and HttpDownloadBean, respectively.

There is also brief discussion of DownloadServlet, provided with OC4J to perform the actual file downloading, and the class FileAccessException that is used by the file-access JavaBeans for exceptions relating to file uploads and downloads.

To comply with the JavaBean specification, the file upload and download JavaBeans provide no-argument constructors.


Note:

To use the file upload and download JavaBeans, verify that the file ojsputil.jar is installed and in your classpath. This file is provided with OC4J.


The HttpUploadBean

The oracle.jsp.webutil.fileaccess.HttpUploadBean JavaBean provides numerous setter methods for specifying information used for the uploading. It also includes most corresponding getter methods. Once you have set all the required and appropriate attributes, use the upload() method to perform the upload. There is also a method to display the names of the files that were uploaded, typically so you can provide an informative message to the browser.

HttpUploadBean, as with HttpDownloadBean, extends HttpFileAccessBean, which itself is not intended for public use.

See "Overview of File Uploading" for related information.

Summary of Required Attributes

The following list summarizes required attributes for HttpUploadBean:

In addition, for an upload to a file system, you must call the setBaseDir() method to provide a servlet context and HTTP request object so that the bean can find the fileaccess.properties file that specifies the base directory.

Methods

Here are descriptions of the public methods of HttpUploadBean.


Note:

Many of the attributes and setter methods for HttpUploadBean are the same as for HttpDownloadBean.



Note:

Typically, the destination value will be based at least partially on user input.


Example:

This example uses a plain HTML form to specify a file to upload to a file system, then uses a JSP page that employs HttpUploadBean for the upload.

Here is the HTML form, which specifies beanUploadExample.jsp for its action and will generate the multipart upload stream.


Note:

Remember to set the base directory appropriately for uploads to a file system. See "File System Destination".


<html><body>
<form action="beanUploadExample.jsp" ENCTYPE="multipart/form-data" method=POST>
<br> File to upload: <INPUT TYPE="FILE" NAME="File" SIZE="50" MAXLENGTH="120" >
<br><INPUT TYPE="SUBMIT" NAME="Submit" VALUE="Send"> </form>
</body></html>

And here is the beanUploadExample.jsp page.

<%@ page language="java" 
         import="java.util.*, oracle.jsp.webutil.fileaccess.*" %>
<html><body>
<% String userdir = "fileaccess"; %>   // user's part of the upload directory
<jsp:useBean id="upbean" 
   class="oracle.jsp.webutil.fileaccess.HttpUploadBean" >
   <jsp:setProperty name="upbean" property="destination" 
                     value="<%= userdir %>" />
</jsp:useBean>
<%   upbean.setBaseDir(application, request);
         upbean.upload(request); 
         Enumeration fileNames = upbean.getFileNames();
         while (fileNames.hasMoreElements()) { %>
              <br><%= (String)fileNames.nextElement() %>
  <% } %>
<br>Done!
</body></html>

The HttpDownloadBean

The oracle.jsp.webutil.fileaccess.HttpDownloadBean JavaBean provides numerous setter methods for specifying information used for downloading. It also includes most corresponding getter methods. Once you have set all the required and appropriate attributes, use the listFiles() method to list the files available for download. The actual downloading is accomplished through DownloadServlet, supplied with OC4J, one file at a time. See "The Download Servlet".


Note:

You must construct the URL for DownloadServlet in your application code.


HttpDownloadBean, as with HttpUploadBean, extends HttpFileAccessBean, which itself is not intended for public use.

See "Overview of File Uploading" for related information.

Summary of Required Attributes

The following list summarizes required attributes for HttpDownloadBean:

In addition, for a download from a file system, you must call the setBaseDir() method to provide a servlet context and HTTP request object so that the bean can find the fileaccess.properties file that specifies the base directory.

Methods

Here are descriptions of the public methods of HttpDownloadBean.


Note:

Many of the attributes and setter methods for HttpDownloadBean are the same as for HttpUploadBean.



Note:

The listFiles() method writes the file names to memory and to the JSP page or servlet. If you later want to access the file names again, use the getFileNames() method to read them from memory.



Note:

Typically, the source value will be based at least partially on user input.


Example

This example is a JSP page that uses HttpDownloadBean for a download from a file system. Note that the page must construct the URL for the download servlet.

<%@ page language="java" import="java.util.*, oracle.jsp.webutil.fileaccess.*" 
%>
<html><body>
<% String servletPath = "/servlet/download/";  // path to the download servlet
   String userDir = "fileaccess/";   // user part of  download directory
%>
<jsp:useBean id="dbean" 
   class="oracle.jsp.webutil.access.HttpDownloadBean" >
   <jsp:setProperty name="dbean" property="source" value='<%=userDir %>' />
</jsp:useBean>
<%    dbean.setBaseDir(application, request);   
          dbean.listFiles(request); %>
The following files were found:
<%   Enumeration fileNames = dbean.getFileNames(); 
         while (fileNames.hasMoreElements()) { 
                String name = (String)fileNames.nextElement();  %>
               <br><a href="<%= servletPath + name %>" > <%= name %></a>
<%    } %>
<br>Done!
</body></html>

The Download Servlet

To use download functionality, through either HttpDownloadBean or the httpDownload tag, you must have the class oracle.jsp.webutil.fileaccess.DownloadServlet available in your Web server. Its mapping in your Web server must be reflected in your servlet path settings, either through the servletPath attribute if you use the httpDownload tag, or in your application code if you use HttpDownloadBean.

FileAccessException Class

The oracle.jsp.webutil.fileaccess.FileAccessException class is a convenience class supplied with OC4J for file-access exception-handling. It wraps the functionality of the standard java.sql.SQLException and java.io.IOException classes. It handles exceptions from either of the file-access beans in addition to handling SQL and I/O exceptions.

File Upload and Download Tag Descriptions

For file uploading, OC4J supplies the httpUpload tag. This tag, in turn, uses HttpUploadBean. For convenience, you can also use the httpUploadForm tag in programming the form through which users specify the files to upload, or you can code the form manually.

For file downloading, OC4J provides the custom httpDownload tag.This tag uses HttpDownloadBean. This section describes these tags and their attributes.

Note the following requirements for the file upload and download tags:

You can refer to the Oracle Application Server Containers for J2EE Support for JavaServer Pages Developer's Guide for information about taglib directives, the well-known tag library directory, TLD files, and the meaning of uri values.


Notes:

  • The prefix "fileaccess:" is used in the tag syntax here. This is by convention but is not required. You can specify any desired prefix in your taglib directive.

  • See "Tag Syntax Symbology and Notes" for general information about tag syntax conventions in this manual.


The httpUploadForm Tag

For convenience, you can use the httpUploadForm tag to create a form in your application, using multipart encoded form data, that allows users to specify the files to upload.

Syntax

<fileaccess:httpUploadForm formsAction = "action" 
                         [ maxFiles = "max_number" ]
                         [ fileNameSize = "file_input_box_num_chars" ]
                         [ maxFileNameSize = "max_file_name_num_chars" ]
                         [ includeNumbers = "true" | "false" ]
                         [ submitButtonText = "button_label_text" ] />


Note:

The httpUploadForm tag can optionally use a body. For example, the body might consist of a user prompt.


Attributes

The httpUpload Tag

This tag wraps the functionality of the HttpUploadBean JavaBean, paralleling its attributes. See "Overview of File Uploading" and "The HttpUploadBean" for related information.

Syntax

<fileaccess:httpUpload destination = "dir_path_or_prefix"
                 [ destinationType = "filesystem" | "database" ]
                 [ connId = "id" ]
                 [ scope = "request" | "page" | "session" | "applicaton" ]
                 [ overwrite = "true" | "false" ]
                 [ fileType = "character" | "binary" ]
                 [ table = "table_name" ]
                 [ prefixColumn = "column_name" ]
                 [ fileNameColumn = "column_name" ]
                 [ dataColumn = "column_name" ] />


Note:

For uploads to a file system, the base directory is automatically retrievable by the tag handler from the JSP page context.


Attributes


Note:

Typically, the destination value will be based at least partially on user input.


Example

This example has a page that uses the httpUploadForm tag to create the HTML form for specifying files to upload. The httpUploadForm tag specifies httpUploadExample.jsp as its forms action. The httpUploadExample.jsp page uses the httpUpload tag to upload to the default fileaccess table in a database.

Here is the page for the HTML form:

<%@ page language="java" import="java.io.*"  %>
<%@ taglib uri="http://xmlns.oracle.com/j2ee/jsp/tld/ojsp/fileaccess.tld"
           prefix="upload" %>
<html> <body>
<fileaccess:httpUploadForm 
      formsAction="httpUploadExample.jsp"
      maxFiles='<%= request.getParameter("MaxFiles") %>'
      includeNumbers="true"  fileNameSize="50"  maxFileNameSize="120" >
          <br> File:
</fileaccess:httpUploadForm>
</body> </html> 

And following is the httpUploadExample.jsp page. Note that the httpUpload tag gets its database connection as a result of being inside a dbOpen tag. Also note that useDataSource.jsp is used to obtain the connection, if necessary. See "useDataSource.jsp".

<%@ page language="java" %>
<%@ taglib uri="http://xmlns.oracle.com/j2ee/jsp/tld/ojsp/fileaccess.tld"
           prefix="upload" %>
<%@ taglib uri="http://xmlns.oracle.com/j2ee/jsp/tld/ojsp/sqltaglib.tld"
           prefix="sql" %>
<% String dataSrcStr=request.getParameter("dataSrcStr"); // get conn string
   if (dataSrcStr==null) {  dataSrcStr=(String)session.getValue("dataSrcStr"); }
   else {  session.putValue("dataSrcStr",dataSrcStr); }
   if (dataSrcStr==null) { %>
       <jsp:forward page="useDataSource.jsp" />
<% } %>
<html><body>
<sql:dbOpen dataSource="<%= dataSrcStr %>" >
   <fileaccess:httpUpload  destinationType = "database"
                           destination="tagexample" />
</sql:dbOpen>
Done! </body></html>


Note:

For the dbOpen tag in this example, assume that the data source specifies the user name and password as well as the URL.


The httpDownload Tag

This tag wraps the functionality of the HttpDownloadBean JavaBean, paralleling its attributes. See "Overview of File Downloading" and "The HttpDownloadBean" for related information.

Syntax

<fileaccess:httpDownload servletPath = "path"
                   source = "dir_path_or_prefix"
                 [ sourceType = "filesystem" | "database" ]
                 [ connId = "id" ]
                 [ scope = "request" | "page" | "session" | "applicaton" ]
                 [ recurse = "true" | "false" ]
                 [ fileType = "character" | "binary" ]
                 [ table = "table_name" ]
                 [ prefixColumn = "column_name" ]
                 [ fileNameColumn = "column_name" ]
                 [ dataColumn = "column_name" ] />


Notes:

  • The httpDownload tag can optionally use a body. For example, the body might consist of a user prompt.

  • For downloads from a file system, the base directory is automatically retrievable by the tag handler from the JSP page context.


Attributes


Note:

Typically, the source value is based at least partially on user input.


Example

This example is a JSP page that uses the httpDownload tag to download from the default fileaccess table of a database. The tag body content ("<br>:") will be output before each file name in the list of files available for download. Note that you must specify the DownloadServlet servlet path in the httpDownload tag. The tag handler will use it in constructing the URL to DownloadServlet, which performs the actual downloading.

<%@ page language="java" %>
<%@ taglib uri="http://xmlns.oracle.com/j2ee/jsp/tld/ojsp/fileaccess.tld"
           prefix="download" %>
<%@ taglib uri="http://xmlns.oracle.com/j2ee/jsp/tld/ojsp/sqltaglib.tld"
           prefix="sql" %>
<% String dataSrcStr=request.getParameter("dataSrcStr");
   if (dataSrcStr==null) { dataSrcStr=(String)session.getValue("dataSrcStr");}
   else { session.putValue("dataSrcStr",dataSrcStr);}
   if (dataSrcStr==null) { %>
      <jsp:forward page="useDataSource.jsp" />
<% } %>
<html> <body>
<% String servletPath = "/servlet/download/"; %>
<sql:dbOpen dataSource="<%= dataSrcStr %>" >
<fileaccess:httpDownload sourceType = "database" 
            source="tagexample" servletPath = `<%= servletPath %>' >
   <br>:
</fileaccess:httpDownload>
</sql:dbOpen>
<br>Done!
</body> </html>


Note:

For the dbOpen tag in this example, assume that the data source specifies the user name and password as well as the URI.


Mail JavaBean and Tag

It is often useful to send e-mail messages from a Web application, based on Web site status or user actions, for example. Sun Microsystems has specified a platform-independent and protocol-independent framework for this through its javax.mail package and subpackages, known as the JavaMail API.

For further convenience, Oracle supplies a JavaBean and JSP custom tag based on the JavaMail API to use in providing e-mail functionality through your servlets or JSP pages. The bean and tag, as with other JavaBeans and custom tags supplied with OC4J, are implemented according to JSP and servlet standards.

The following sections describe the mail JavaBean and tag:


Note:

In Oracle Application Server, the mail JavaBean and tag require the OC4J environment; JServ is not supported.


For more information about the JavaMail API, refer to the following Sun Microsystems Web site:

http://java.sun.com/products/javamail/1.2/docs/javadocs/index.html

General Considerations for the Mail JavaBean and Tag

Be aware of the following points, which apply to use of either the mail JavaBean (SendMailBean) or the mail tag (sendMail):

Mail Attachments

The mail bean and tag support the sending of attachments with e-mail messages. (This support was introduced in the OC4J 9.0.3 implementation.) There are three modes of operation:

For a client-side attachment, the file is automatically uploaded to the server machine as part of the process. Multiple client-side attachments are not supported.

Enabling Attachments

Whether attachments are enabled, and which kind of attachments, is determined by a sendmail.properties file in the application /WEB-INF directory. A file with the following content disables attachments:

## email attachment permissions
sendmail.attachment=none

You must create this file in /WEB-INF and update it appropriately for any OC4J instance that will use mail attachments.

Any single application can support server-side attachments or client-side attachments, but not both.

To enable server-side attachments, change the setting to server, as follows:

sendmail.attachment=server

To enable client-side attachments, change the setting to client:

sendmail.attachment=client

Having multiple settings is an error condition.


Note:

The absence of a sendmail.properties file is treated as equivalent to the presence of sendmail.properties with a setting of none. Mail attachments are disabled in this case.


Sending Attachments

For the mail tag, if server-side attachments are enabled, use the serverAttachment tag attribute if you want to specify one or more server-side files to attach to a message. If client-side attachments are enabled, use the clientAttachment tag attribute if you want to specify a client-side file to attach to a message (maximum of one file). See "The sendMail Tag Description". Note that either one of the two attachment modes, but not both, can be supported for any single application.

For both the server attachment mode and the client attachment mode, the mail bean includes methods to specify or retrieve the name (or names) of the file (or files) to attach. See information about setServerAttachment(), getServerAttachment(), setClientAttachment(), and getClientAttachment() in "SendMailBean Method Descriptions".

With either the mail tag or mail bean, a list of server-side files to attach can be either comma-delimited or semicolon-delimited, but not space-delimited (given that spaces are allowed in file names in some operating systems).

Attachment Usage Notes

Be aware of the following usage notes for mail attachments, applying to both the mail tag and mail bean.

SendMailBean Description

The oracle.jsp.webutil.email.SendMailBean JavaBean is supplied with OC4J to support e-mail functionality from servlet or JSP applications. To use it in a JSP page, you can instantiate it through the standard jsp:useBean tag. (For JSP applications, however, you would typically use the sendMail tag instead of SendMailBean. See "The sendMail Tag Description".)

SendMailBean Requirements

To use SendMailBean, verify that the files ojsputil.jar, mail.jar, and activation.jar are installed and in your classpath. These files are supplied with OC4J.

When you use SendMailBean in your code, you must provide the following:

All other SendMailBean attributes are optional.

SendMailBean Method Descriptions

This section lists and describes SendMailBean methods to send mail messages, close mail sessions, and set or get bean attributes.


Note:

To comply with the JavaBean specification, SendMailBean has a no-argument constructor.


Here are the public SendMailBean methods:


Note:

Regarding mail attachments, see "Mail Attachments" for related information. Be aware that for any one application, you can use server-side attachments or client-side attachments but not both.


The sendMail Tag Description

As a convenience for JSP developers, OC4J supplies the sendMail tag to provide e-mail functionality for a JSP page. The following sections describe the tag:

Be aware of the following requirements for the sendMail tag:

You can refer to the Oracle Application Server Containers for J2EE Support for JavaServer Pages Developer's Guide for information about taglib directives, the well-known tag library directory, TLD files, and the meaning of uri values.

The sendMail Tag Syntax

The sendMail tag has the following syntax:

<mail:sendMail host = "SMTP_host_name" | session = "JavaMail_session_name" 
               sender = "sender_address"
               recipient = "primary_recipient_IDs"
             [ cc = "cc_recipient_IDs" ]
             [ bcc = "bcc_recipient_IDs" ] 
             [ subject = "subject_line" ]
             [ contentType = "MIME_type; [charset=charset]" ]
             [ contentEncoding = "B"|"base64"|"Q"|"quoted-printable"|
                                 "7bit"|"8bit" ]
             [ serverAttachment = "server_file_list" | 
               clientAttachment = "client_file" ] >
...
E-mail body
...
</mail:sendMail>
sendMail Tag Usage Notes

Be aware of the following when using the sendMail tag:

The sendMail Tag Attribute Descriptions

The sendMail tag supports the following attributes:


Note:

Regarding e-mail attachments, see "Mail Attachments" for related information. Be aware that for any one application, you can use server-side attachments or client-side attachments but not both.


Sample Application for sendMail Tag

This sample application illustrates use of the sendMail tag with no attachments. During the first execution cycle through the page, before the user has specified the sender (or anything else), the HTML form is displayed for user input. During the next execution cycle through the page, after the user has sent the input, the sendMail tag is executed. This page also uses an error page, error.jsp (shown below), to display any exceptions that are thrown.

<%@ page language="java" errorPage="error.jsp" %>
<%@ taglib uri="http://xmlns.oracle.com/j2ee/jsp/tld/ojsp/email.tld"
           prefix="mail" %>
<% if (request.getParameter("sender")==null) { %>
<HTML>
<HEAD><TITLE>SendMail Sample</TITLE></HEAD>
<FORM METHOD=post>
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="20%">
<TR><TD>Host:</TD><TD><INPUT TYPE="text" name="host" ></TD></TR>
<TR><TD>From:</TD><TD><INPUT TYPE="text" name="sender" ></TD></TR>
<TR><TD>To:</TD><TD><INPUT TYPE="text" name="recipient"  ></TD></TR>
<TR><TD>Cc:</TD><TD><INPUT TYPE="text" name="cc" ></TD></TR>
<TR><TD>Bcc:</TD><TD><INPUT TYPE="text" name="bcc" ></TD></TR>
<TR><TD>Subject:</TD><TD><INPUT TYPE="text" name="subject"
VALUE="Hi"></TD></TR>
</TABLE><br>
<TEXTAREA name="body" ROWS=4 COLS=30>"How are you!"</TEXTAREA><br><br>
<INPUT TYPE="submit" value="Send">
</FORM>
<%
}
else{
%>
<BODY BGCOLOR="#FFFFFF">
<P>Result:
       <HR>
       <mail:sendMail host='<%=request.getParameter("host")%>'
             sender='<%=request.getParameter("sender")%>'
             recipient='<%=request.getParameter("recipient")%>'
             cc='<%=request.getParameter("cc")%>'
             bcc='<%=request.getParameter("bcc")%>'
             subject='<%=request.getParameter("subject")%>'>
             <%=request.getParameter("body")%>
       </mail:sendMail>
Sent out Successfully!
       <HR>
</BODY>
<%
}
%>
</HTML>

Here is the error page, error.jsp:

<%@ page language="java" isErrorPage="true"%>
<HTML>
Error: <%= exception.getMessage() %>
</HTML>

When you run this application, you will initially see the following default screen:

Text description of smaildef.gif follows.

Text description of the illustration smaildef.gif

And here is sample user input for a message from brian.wright@oracle.com to blodney.treehut@oracle.com through the host gmail.oraclecorp.com:

Text description of smailtst.gif follows.

Text description of the illustration smailtst.gif


Go to previous page Go to next page
Oracle
Copyright © 2002, 2003 Oracle Corporation.

All Rights Reserved.
Go To Documentation Library
Home
Go To Table Of Contents
Contents
Go To Index
Index