发送E-mail的jsp页面sendmail.jsp<%@ page import="javax.mail.*,javax.mail.internet.*,
      javax.activation.*,java.util.*" %>
<html>
  <head>
    <title>javamail example</title>
  </head>
 
  <body>
   <%
     try{
       Properties props=new Properties();
       Session sendMailSession;
       Transport transport;
       sendMailSession=Session.getInstance(props,null);
       props.put("mail.smtp.host","localhost");
       Message newMessage=new MineMessage(sendMailSession);
       newMessage.setFrom(new InternetAddress(
          request.getParameter("from")));
       newMessage.setRecipient(Message.RecipientType.TO,
          new InternetAddress(request.getParameter("to")));
       newMessage.setSentDate(new Date());
       newMessage.setText(request.getParameter("text"));
       transport=sendMailSession.getTransport("smtp");
       transport.send(newMessage);
   %>
      <p>Your mail has been sent.</p>
   <%
     }catch(MessagingException m)
       { out.println(m.toString()); }
   %>
  </body>
</html>
页面错误:
HTTP Status 500 - --------------------------------------------------------------------------------type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: Unable to compile class for JSPAn error occurred at line: 9 in the jsp file: /jsp/sendmail.jsp
Generated servlet error:
Session cannot be resolved to a typeAn error occurred at line: 9 in the jsp file: /jsp/sendmail.jsp
Generated servlet error:
Transport cannot be resolved to a typeAn error occurred at line: 9 in the jsp file: /jsp/sendmail.jsp
Generated servlet error:
Session cannot be resolvedAn error occurred at line: 9 in the jsp file: /jsp/sendmail.jsp
Generated servlet error:
Message cannot be resolved to a typeAn error occurred at line: 9 in the jsp file: /jsp/sendmail.jsp
Generated servlet error:
MineMessage cannot be resolved to a typeAn error occurred at line: 9 in the jsp file: /jsp/sendmail.jsp
Generated servlet error:
InternetAddress cannot be resolved to a typeAn error occurred at line: 9 in the jsp file: /jsp/sendmail.jsp
Generated servlet error:
Message.RecipientType.TO cannot be resolved to a typeAn error occurred at line: 9 in the jsp file: /jsp/sendmail.jsp
Generated servlet error:
InternetAddress cannot be resolved to a typeAn error occurred at line: 27 in the jsp file: /jsp/sendmail.jsp
Generated servlet error:
MessagingException cannot be resolved to a typeAn error occurred at line: 27 in the jsp file: /jsp/sendmail.jsp
Generated servlet error:
m cannot be resolved我在jdk5.0的api文档中怎么找不到javax.mail这些东西,谁能帮帮我怎样用java/jsp写出一个收发邮件的简单的东西

解决方案 »

  1.   

    你的那些包mail包放在哪里?应该放到lib下
      

  2.   

    去http://java.sun.com/products/javamail下载java mail API就有mail.jar文件了,包含了java mail API中所有的借口和类
      

  3.   

    然后再下载javabeans activation framework,得到activation.jar文件
    http://java.sun.com/beans/glasgow/jaf.html
      

  4.   

    页面编译通过,
    但返回信息:
    javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25; nested exception is: java.net.ConnectException: Connection refused: connect这又是哪些方面的原因,这个东西与25号端口有关系吗
      

  5.   

    搂住需要补补网络课了,这是发送邮件的程序,需要连接到smtp服务器
    程序里用的是本地主机,相信你一定没有安装smtp服务
    可以用免费邮箱的服务器,但是现在都要发信身份认证
     sendMailSession=Session.getInstance(props,null);
    这一句要改了
      

  6.   

    我现在学这些东西,写这些东西主要是查api文档来做的,不知zhblue能否给我补一补这方面的课,给简单讲下原理,帮忙解决下.
      

  7.   

    另外,我以前在tomcat 5.5的目录中的不知哪个文件夹中找到过jstl.jar包,现在怎么也想不起来,各位大哥谁知道,或网上怎样下到,感谢说一声。