当前位置: 技术问答>java相关
JavaBean奇怪问题,高人Please come in!!
来源: 互联网 发布时间:2015-10-15
本文导语: 我把以下代码编译成Class文件放在WEB-INFclassessendmail_pkg package sendmail_pkg; import java.util.*; import javax.mail.*; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; public class ...
我把以下代码编译成Class文件放在WEB-INFclassessendmail_pkg
package sendmail_pkg;
import java.util.*;
import javax.mail.*;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
public class sendmail
{
boolean ok;
public sendmail()
{
ok = false;
}
public boolean isSendOk(String username, String pwd, String e_mail)
{
try
{
String sendStr = String.valueOf(String.valueOf((new StringBuffer("你的用户名:")).append(username).append(" ").append("密码:").append(pwd)));
Properties props = new Properties();
Session sendMailSession = Session.getInstance(props, null);
props.put("mail.smtp.host", "smtp.163.com");
props.put("mail.smtp.auth", "true");
Message newMessage = new MimeMessage(sendMailSession);
newMessage.setFrom(new InternetAddress("cdx257@163.com"));
newMessage.setRecipient(javax.mail.Message.RecipientType.TO, new InternetAddress(e_mail));
newMessage.setSubject("TEST");
newMessage.setSentDate(new Date());
newMessage.setText(sendStr);
Transport transport = sendMailSession.getTransport("smtp");
newMessage.saveChanges();
transport.connect("smtp.163.com", "cdx257", "TESTTESET");
transport.sendMessage(newMessage, newMessage.getRecipients(javax.mail.Message.RecipientType.TO));
transport.close();
ok = true;
throw new MessagingException("");
}
catch(MessagingException e)
{
ok = false;
}
return ok;
}
}
可在JSP中调用时提示Undefined variable or class name: sendMailBean
ok=sendMailBean.isSendOk(username,pwd,e_mail);
^
.......
String username="username";
String pwd="AAA",e_mail="cdx257@163.com";
int ID=0;boolean ok=false;
ok=sendMailBean.isSendOk(username,pwd,e_mail);
.......
可是connSqlBean以能正确的调用
请问如何解决?(我重启过TOMCAT,重启过电脑还是一样的错,我的环境:JDK1.3+TOMCAT4.0+W2KSERVER)
package sendmail_pkg;
import java.util.*;
import javax.mail.*;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
public class sendmail
{
boolean ok;
public sendmail()
{
ok = false;
}
public boolean isSendOk(String username, String pwd, String e_mail)
{
try
{
String sendStr = String.valueOf(String.valueOf((new StringBuffer("你的用户名:")).append(username).append(" ").append("密码:").append(pwd)));
Properties props = new Properties();
Session sendMailSession = Session.getInstance(props, null);
props.put("mail.smtp.host", "smtp.163.com");
props.put("mail.smtp.auth", "true");
Message newMessage = new MimeMessage(sendMailSession);
newMessage.setFrom(new InternetAddress("cdx257@163.com"));
newMessage.setRecipient(javax.mail.Message.RecipientType.TO, new InternetAddress(e_mail));
newMessage.setSubject("TEST");
newMessage.setSentDate(new Date());
newMessage.setText(sendStr);
Transport transport = sendMailSession.getTransport("smtp");
newMessage.saveChanges();
transport.connect("smtp.163.com", "cdx257", "TESTTESET");
transport.sendMessage(newMessage, newMessage.getRecipients(javax.mail.Message.RecipientType.TO));
transport.close();
ok = true;
throw new MessagingException("");
}
catch(MessagingException e)
{
ok = false;
}
return ok;
}
}
可在JSP中调用时提示Undefined variable or class name: sendMailBean
ok=sendMailBean.isSendOk(username,pwd,e_mail);
^
.......
String username="username";
String pwd="AAA",e_mail="cdx257@163.com";
int ID=0;boolean ok=false;
ok=sendMailBean.isSendOk(username,pwd,e_mail);
.......
可是connSqlBean以能正确的调用
请问如何解决?(我重启过TOMCAT,重启过电脑还是一样的错,我的环境:JDK1.3+TOMCAT4.0+W2KSERVER)
|
是jsp:useBean不是userBean,粗心!