站内搜索: 请输入搜索关键词

当前页面: 开发资料首页J2EE 专题高分求助(在线等): Eclipse+myeclipse 导入javax.mail.Session时错误????

高分求助(在线等): Eclipse+myeclipse 导入javax.mail.Session时错误????

摘要: 高分求助(在线等): Eclipse+myeclipse 导入javax.mail.Session时错误????


程序没有问题,可是在运行时,却提示出: 找不到javax.mail.Session包
可是到项目库中却能在其中找到.不知道是什么原因????


程序如下:

<%@ page language="java" import="java.util.*,javax.mail.*,javax.mail.internet.*,javax.activation.*" pageEncoding="UTF-8"%>
<%@ page import="javax.mail.Session" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<head>
<%
if(request.getParameter("OK") != null){
String host = "smtp.21cn.com";
String from = "wdmzjsxx@21cn.com";
String to = "songxiao5@21cn.com";
try{
Properties prop = System.getProperties();
prop.put("mail.smtp.host",host);
prop.put("mail.smtp.auth","true");
javax.mail.Session s = javax.mail.Session.getDefaultInstance(prop,null);
MimeMessage message = new MimeMessage(s);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO,new InternetAddress(to));
message.setSubject("Hello JavaMail");
message.setText("welcome to china....");
Transport transport = s.getTransport("smtp");
transport.connect(host,"wdmzjsxx@21cn.com","*********");
transport.send(message,message.getAllRecipients());
transport.close();
}
catch(Exception e){
e.printStackTrace();
}
}
%>


My JSP 'MyJsp.jsp' starting page








↑返回目录
前一篇: 刚看完java2入门经典,jsp方面看什么书入门较好?
后一篇: “无法显示网页”的问题?