<%@ page import="oracle.sql.*, oracle.jdbc.driver.*, oracle.jdbc.*, java.sql.*"  errorPage="error.jsp" contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="http://xmlns.oracle.com/j2ee/jsp/tld/ojsp/email.tld" prefix="mail" %>

<% String connStr=request.getParameter("connStr");
   if (connStr==null) {
     connStr=(String)session.getValue("connStr");
   } else {
     session.putValue("connStr",connStr);
   }

   String smtpHost = request.getParameter("smtpHost");
   if( smtpHost==null) {
     smtpHost=(String)session.getValue("smtpHost");
   } else {
     session.putValue("smtpHost", smtpHost);
   }

   if (connStr==null || smtpHost==null) { %>
<jsp:forward page="setup_db_mail.jsp" />
<%
   }

   String sender = request.getParameter("sender");
   String recipient = request.getParameter("recipient");
   if( sender == null ) sender = "";
   if( recipient == null ) recipient = "";
   sender = sender.trim();
   recipient = recipient.trim();
%>
<HTML>
<HEAD><TITLE>SendMail Sample</TITLE></HEAD>
<BODY BGCOLOR="#FFFFFF">
<FORM METHOD=post>
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="40%">
<TR><TD>DB connect:</TD><TD><%=connStr%></TD></TR>
<TR><TD>SMTP host:</TD><TD><%=smtpHost%></TD></TR>
<TR><TD>From:</TD><TD><INPUT TYPE="text" name="sender" value="<%=sender%>"></TD></TR>
<TR><TD>To:</TD><TD><INPUT TYPE="text" name="recipient" value="<%=recipient%>"></TD></TR>
<TR><TD>Subject:</TD><TD><INPUT TYPE="text" name="subject"
VALUE="Send Cache Content"></TD></TR>
</TABLE><br>
<INPUT TYPE="submit" value=" Send It! ">
</FORM>
<jsp:include page="viewdata.jsp?style=html"/>
<% if( !"".equals(sender) && !"".equals(recipient) ) { %>
<HR>
<mail:sendMail host='<%=smtpHost%>'
             sender='<%=sender%>'
             recipient='<%=recipient%>'
             subject='<%=request.getParameter("subject")%>'>
<jsp:include page="viewdata.jsp?style=mail"/>
</mail:sendMail>
Sent out Successfully!
</BODY>
<%
}
%>
