• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java mail problem

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
J2SDK (1.3.0_02) on Windows 2000 Server with SP1
Hi all
I have a JSP which calls a bean (which I did not write) that sends an email after a banking transaction has taken place (transfer of funds between two accounts).
I want to add some additional information to the message, by passing the following parameters to the bean: source account, destination account, date and amount. Currently, the bean is expecting to receive a recipient email address, the name of the sender, the name of the mail host server, the subject of the email and a debug flag (true or false).
If I add these new parameters to the sendMail method declaration, the .java file compiles fine, but when the JSP calls the bean the error message reads 'Wrong number of arguments in method'.
Any ideas how I can this extra information? I have a feeling that something lurking in the depths of javax.mail.* is the issue, but would be grateful of any help as I don't see anything obvious there.
TIA
Clive.
------------------------------------------------
First code block - works fine:

-------------------------------------------------
Second code block, throws the error:

Added the UBB code tags for easier reading--Carl
[ February 13, 2002: Message edited by: Carl Trusiak ]
 
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What does the code to your jsp page look like? From the appearance, neither one of these classes could function fully as a JSP Bean tough you could work around that.
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also clive,
Please note that JavaRanch has a Naming Policy please read and follow it.
 
Clive van Hilten
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply Carl. Have amended my profile to comply with naming convention, sorry about that.

Here is the JSP that calls the MailBean:


<%@ taglib uri="/WEB-INF/tld/oui.tld" prefix="oui" %>
<%@ page language="java" import="ariel.MailDetails, java.util.*,
java.sql.*,
oracle.jdbc.driver.*" %>
<jsp:useBean id="signon" scope="session" class="ariel.LogonBean" />
<jsp:useBean id="bank" scope="request" class="ariel.BankingBean" />
<jsp:useBean id="mailer" scope="request" class="ariel.MailBean" />

<%
//transfer.jsp is used to update the database with details of a funds
transfer
//and to send a confirmatory email to the user
%>


<oui:wml>

<%
String strId = request.getParameter("id");
String strFrom = request.getParameter("from");
String strTo = request.getParameter("to");
String strAmount = request.getParameter("amt");
String strDate = request.getParameter("date");

Hashtable hashtable = new Hashtable();

hashtable = bank.getMail(strId);

if ( request.getParameter("amt") == null)
{
%>
<oui:card id="error" title="Amount error">
<oui:p align="left">
Transfer amount must be submitted. Please go back.
</oui:p>
</oui:card>
<%
}
else if ( request.getParameter("from")==null ||
request.getParameter("to")
==null )
{
%>
<oui:card id="error" title="A/c error">
<oui:p align="left">
Both accounts must be selected. Please go back.
</oui:p>
</oui:card>
<%
}
else
{

Connection conn = null;
try{
DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
String url = "jdbc:oracle:thin:ariel/ariel@127.0.0.1:1521:ariel" ;
conn = DriverManager.getConnection( url );
System.out.println("1");
PreparedStatement stmt = conn.prepareStatement ("{call
P_FUNDS_TRANSFER(?,?,?)}");
System.out.println("2");
stmt.setString(1, request.getParameter("from"));
System.out.println("3");
stmt.setString(2, request.getParameter("to"));
System.out.println("4");
stmt.setFloat(3, new Float(request.getParameter("amt")).floatValue()
);
System.out.println("5");
stmt.execute();

System.out.println("6");
%>
<oui:card id="transconfirm" title="Transfer Funds">
<oui:p align="left">
<oui:img alt="Done" localsrc="checkmark1" src ="" >
</oui:img>
Successful transaction completion.
<oui:hr/>
<oui:primary_path short_label="Balances">
<oui:go href='<%="balance.jsp?id=" + strId%>'/>
</oui:primary_path>
<oui:secondary_path short_label="Main">
<oui:go href='<%="../asignon/revalidate.jsp?id=" +
strId%>'/>
</oui:secondary_path>
</oui:p>
</oui:card>
<%
MailDetails md = new MailDetails();

for (Enumeration e = hashtable.elements() ;
e.hasMoreElements() ;)
{
md = (MailDetails) e.nextElement();


mailer.sendMail ( md.getMail(), "bank app.", "10.82.64.9",
"Successful transfer.", true );
}
}

catch(SQLException e)
{
out.println("SQLException: " + e.getMessage() + "*");
while((e = e.getNextException()) != null)
out.println(e.getMessage() + "*");
}
finally
{
//Clean up resources, close the connection.
if(conn != null)
{
try
{
conn.close();
}
catch (Exception ignored) {}
}
}
}

%>

</oui:wml>
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK,
First, this needs moved to JSP.
Second, the mthod signiture you are using in your JSP is
mailer.sendMail ( md.getMail(), "bank app.", "10.82.64.9", "Successful transfer.", true );
In the class it's
sendMail(String recipient, String sender, String host, String subject, boolean debug, String to, String from, String date, String amount )
You are missing several parameters.
There are several good taglibs floating around to for Email. Including Mailer from Jakarta. That will help clean this up a little as would the DBTags
 
Clive van Hilten
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Carl
Not sure why this post has been transferred to the JSP forum.
Regarding the 'incorrect number of parameters', please note that I have posted both versions of the MailBean - the first one works, but I cannot get the second one (which is an edited version of the first with _additional_ parameters added) to work. I cannot see why. I have added the additional parameters everywhere in the bean and in the JSP that calls the bean, and although the bean will compile, the JSP will not - the error message says that there is an incorrect number of arguments.
Note that this JSP compilation error occurs despite that fact that I have edited the JSP to include the _new,_ _expanded_ list of parameters in the call to the bean, like so:
mailer.sendMail ( md.getMail(), "banking app.", "10.82.64.9", "Successful transfer.", true, strTo, strFrom, strDate, strAmount );
Is there something in the javax.mail.* classes that is tripping up this second version of the bean?
Thanks for your help!
Clive
[ February 14, 2002: Message edited by: Clive van Hilten ]
[ February 14, 2002: Message edited by: Clive van Hilten ]
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's in JSP because the I think you can get real help here. I think what could be tripping you up is the fact that both beans have exactly the same name. Change the name of the second bean, change your JSP enough to create and use the second bean and retry this.
Also, as I said, the "MailBean" isn't written to be used properly as a JSP bean. Provide a setXXX for each parameter you want to set. Then on your JSP page Set each property with
<jsp:setProperty name="nameof bean" property="proertyName" value="<%= value %>" />
As a start. It can be refactored further from there.
[ February 14, 2002: Message edited by: Carl Trusiak ]
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
>I want to add some additional information to the message, by passing the
>following parameters to the bean: source account, destination account, date
>and amount.
You're not sending account numbers in emails, right? ;-)
 
reply
    Bookmark Topic Watch Topic
  • New Topic