高分跪求tomcat服务器的配置问题(Session cannot be resolved)

hexcodes 2009-07-17 11:50:14
org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 86 in the jsp file: /global/sendmail.jsp
Session cannot be resolved to a type
83: props.put("mail.smtp.auth", "true");//指定是否需要SMTP验证
84: try
85: {
86: Session mailSession = Session.getDefaultInstance(props);
87:
88: mailSession.setDebug(false);//是否在控制台显示debug信息
89:


An error occurred at line: 86 in the jsp file: /global/sendmail.jsp
Session cannot be resolved



我很多页面都出现这样的错误,希望高手能指点一下,谢谢了。

希望说的详细一点,我对jsp的配置也不懂,好像是设置有错误,就不知道在哪?
...全文
1243 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
Equat 2010-08-16
  • 打赏
  • 举报
回复
我也碰到同样的问题,已解决。
是mail.jar的版本不对,包里面没有Session*.class;用1.4的包正常(可从http://ishare.iask.sina.com.cn/f/8133861.html下载)。
sangshusen_1988 2009-07-17
  • 打赏
  • 举报
回复
没有导包吧
caoyifeng521 2009-07-17
  • 打赏
  • 举报
回复
我也有这样的问题,期待解决中! 谢谢
code_killer 2009-07-17
  • 打赏
  • 举报
回复
找到JavaMail包(jar),然后在你的jsp文件里面import相关的类。
hexcodes 2009-07-17
  • 打赏
  • 举报
回复
这些都是这样的 !
hexcodes 2009-07-17
  • 打赏
  • 举报
回复
org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 86 in the jsp file: /global/sendmail.jsp
Session cannot be resolved to a type
83: props.put("mail.smtp.auth", "true");//指定是否需要SMTP验证
84: try
85: {
86: Session mailSession = Session.getDefaultInstance(props);
87:
88: mailSession.setDebug(false);//是否在控制台显示debug信息
89:


An error occurred at line: 86 in the jsp file: /global/sendmail.jsp
Session cannot be resolved
83: props.put("mail.smtp.auth", "true");//指定是否需要SMTP验证
84: try
85: {
86: Session mailSession = Session.getDefaultInstance(props);
87:
88: mailSession.setDebug(false);//是否在控制台显示debug信息
89:


An error occurred at line: 90 in the jsp file: /global/sendmail.jsp
Message cannot be resolved to a type
87:
88: mailSession.setDebug(false);//是否在控制台显示debug信息
89:
90: Message message=new MimeMessage(mailSession);
91: if(textcontent!="") //邮件的纯文本内容
92: message.setText(textcontent);
93:


An error occurred at line: 90 in the jsp file: /global/sendmail.jsp
MimeMessage cannot be resolved to a type
87:
88: mailSession.setDebug(false);//是否在控制台显示debug信息
89:
90: Message message=new MimeMessage(mailSession);
91: if(textcontent!="") //邮件的纯文本内容
92: message.setText(textcontent);
93:


An error occurred at line: 7 in the jsp file: /global/sendmail.jsp
InternetAddress cannot be resolved to a type
4: <%@ page import="javax.mail.internet.*"%>
5: <%@ page import="javax.activation.*"%><%/* for attachment */%>
6:
7: <%!
8:
9: public class mySmtpSendMail
10: {


An error occurred at line: 7 in the jsp file: /global/sendmail.jsp
InternetAddress cannot be resolved to a type
4: <%@ page import="javax.mail.internet.*"%>
5: <%@ page import="javax.activation.*"%><%/* for attachment */%>
6:
7: <%!
8:
9: public class mySmtpSendMail
10: {


An error occurred at line: 7 in the jsp file: /global/sendmail.jsp
Message.RecipientType.TO cannot be resolved to a type
4: <%@ page import="javax.mail.internet.*"%>
5: <%@ page import="javax.activation.*"%><%/* for attachment */%>
6:
7: <%!
8:
9: public class mySmtpSendMail
10: {


An error occurred at line: 7 in the jsp file: /global/sendmail.jsp
InternetAddress cannot be resolved to a type
4: <%@ page import="javax.mail.internet.*"%>
5: <%@ page import="javax.activation.*"%><%/* for attachment */%>
6:
7: <%!
8:
9: public class mySmtpSendMail
10: {


An error occurred at line: 7 in the jsp file: /global/sendmail.jsp
Message.RecipientType.CC cannot be resolved to a type
4: <%@ page import="javax.mail.internet.*"%>
5: <%@ page import="javax.activation.*"%><%/* for attachment */%>
6:
7: <%!
8:
9: public class mySmtpSendMail
10: {


An error occurred at line: 7 in the jsp file: /global/sendmail.jsp
InternetAddress cannot be resolved to a type
4: <%@ page import="javax.mail.internet.*"%>
5: <%@ page import="javax.activation.*"%><%/* for attachment */%>
6:
7: <%!
8:
9: public class mySmtpSendMail
10: {


An error occurred at line: 7 in the jsp file: /global/sendmail.jsp
Message.RecipientType.BCC cannot be resolved to a type
4: <%@ page import="javax.mail.internet.*"%>
5: <%@ page import="javax.activation.*"%><%/* for attachment */%>
6:
7: <%!
8:
9: public class mySmtpSendMail
10: {


An error occurred at line: 7 in the jsp file: /global/sendmail.jsp
InternetAddress cannot be resolved to a type
4: <%@ page import="javax.mail.internet.*"%>
5: <%@ page import="javax.activation.*"%><%/* for attachment */%>
6:
7: <%!
8:
9: public class mySmtpSendMail
10: {


An error occurred at line: 115 in the jsp file: /global/sendmail.jsp
Multipart cannot be resolved to a type
112: message.setSubject(this.subject); //邮件主题
113:
114: if(htmlcontent!="" || attachment!=""){ //html格式或者包括附件
115: Multipart container=new MimeMultipart();
116: MimeBodyPart tBodyPart;
117: if(htmlcontent!=""){ //邮件的html内容
118: tBodyPart=new MimeBodyPart();


An error occurred at line: 115 in the jsp file: /global/sendmail.jsp
MimeMultipart cannot be resolved to a type
112: message.setSubject(this.subject); //邮件主题
113:
114: if(htmlcontent!="" || attachment!=""){ //html格式或者包括附件
115: Multipart container=new MimeMultipart();
116: MimeBodyPart tBodyPart;
117: if(htmlcontent!=""){ //邮件的html内容
118: tBodyPart=new MimeBodyPart();


An error occurred at line: 116 in the jsp file: /global/sendmail.jsp
MimeBodyPart cannot be resolved to a type
113:
114: if(htmlcontent!="" || attachment!=""){ //html格式或者包括附件
115: Multipart container=new MimeMultipart();
116: MimeBodyPart tBodyPart;
117: if(htmlcontent!=""){ //邮件的html内容
118: tBodyPart=new MimeBodyPart();
119: tBodyPart.setContent(htmlcontent,"text/html; charset=GBK");


An error occurred at line: 118 in the jsp file: /global/sendmail.jsp
MimeBodyPart cannot be resolved to a type
115: Multipart container=new MimeMultipart();
116: MimeBodyPart tBodyPart;
117: if(htmlcontent!=""){ //邮件的html内容
118: tBodyPart=new MimeBodyPart();
119: tBodyPart.setContent(htmlcontent,"text/html; charset=GBK");
120: container.addBodyPart(tBodyPart);
121: }


An error occurred at line: 118 in the jsp file: /global/sendmail.jsp
MimeBodyPart cannot be resolved to a type
115: Multipart container=new MimeMultipart();
116: MimeBodyPart tBodyPart;
117: if(htmlcontent!=""){ //邮件的html内容
118: tBodyPart=new MimeBodyPart();
119: tBodyPart.setContent(htmlcontent,"text/html; charset=GBK");
120: container.addBodyPart(tBodyPart);
121: }


An error occurred at line: 137 in the jsp file: /global/sendmail.jsp
Transport cannot be resolved to a type
134: message.saveChanges();
135: i=1;
136:
137: Transport transport = mailSession.getTransport("smtp");
138: i=2;
139: transport.connect(host, user, password);
140: i=3;


Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:93)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:435)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:298)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:277)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:265)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:302)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
zhang_yu_QIN 2009-07-17
  • 打赏
  • 举报
回复
把JSP的代码贴出来看看.
radeonxhl 2009-07-17
  • 打赏
  • 举报
回复
1.确保所有jsp中都有这两句
<%@ page import="javax.mail.internet.*"%>
<%@ page import="javax.mail.*"%>

2.确保mail.jar放在了应用的lib下面(而不是tomcat的lib)
hexcodes 2009-07-17
  • 打赏
  • 举报
回复
在线等,那位高手指点下啊 !
hexcodes 2009-07-17
  • 打赏
  • 举报
回复
我下载的mail包中还有其它好多东西 这些东西都还要吗? 是不是只要mail.jar这一个就可以了?其它文件都不用要了?
xuwu1010 2009-07-17
  • 打赏
  • 举报
回复
放在 项目的 /lib文件夹 下 再上传到Tomcat 服务器 上 也许 能解救 你遇到的 问题 试试 !!!!!!!!
hexcodes 2009-07-17
  • 打赏
  • 举报
回复
<%@ page contentType="text/html; charset=GBK" buffer="48kb"%>
<%@ include file="/global/config.jsp" %>
<%@ include file="/global/sendmail.jsp" %>
<%!
int CurrentChannel=1, CurrentTitle=4;
%>
<%@ include file="/global/sop.jsp" %>
<%@ page import="javax.mail.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="javax.sql.*"%>
<%@ page import="javax.naming.*"%>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.List" %>
<%
if(!haveTitleRight(CurrentChannel, CurrentTitle, (String)session.getAttribute("ses_usertype"+CurrentChannel))){
response.sendRedirect(Channels[CurrentChannel][0][1]);
return;
}

int error=0;
String errorstr="";
response.setHeader("Pragma", "no-cache"); //HTTP 1.0

String ids=request.getParameter("id");
int id=0;
if(ids==null || ids=="")
id=0;
else{
try{
id=Integer.parseInt(ids);
}
catch(Exception e){
id=0;
}
}
if(id==0){
response.sendRedirect(Channels[CurrentChannel][CurrentTitle][1]);
return;
}
int usertype=Integer.parseInt((String)session.getAttribute("ses_usertype"+CurrentChannel));
int userid=Integer.parseInt((String)session.getAttribute("ses_userid"+CurrentChannel));
int manager=Integer.parseInt((String)session.getAttribute("ses_manager"+CurrentChannel));
int phonetype=10;

Connection conn = null;
java.sql.Statement stmt = null;
ResultSet rs = null;
try{
InitialContext ctx=new InitialContext();
javax.sql.DataSource ds = (javax.sql.DataSource)ctx.lookup("java:comp/env/jdbc/partner");
conn = ds.getConnection();
stmt = conn.createStatement();
stmt.executeUpdate("set autocommit=0");
}
catch(Exception e){
error=1;
errorstr="数据库连接失败,请重试!";
}

上面是我的一部分源代码,我已经引用这个mail.jar包了,而且我也已经把这个mail.jar包放在了tomcat的common/lib下面了,怎么还是出现同样的问题啊!
duanwq0007 2009-07-17
  • 打赏
  • 举报
回复
放到tomcat lib目录下.
hexcodes 2009-07-17
  • 打赏
  • 举报
回复
像这mail.jar我下载了以后放到哪个目录下啊 ?
wangsen_99997 2009-07-17
  • 打赏
  • 举报
回复
看看你的javamail包真的导入了吗
Johnson_Hong 2009-07-17
  • 打赏
  • 举报
回复
很明显是没有导入包
加入mail.jar

在jsp里import javax.mail.*;

81,090

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧