sendMailServlet.java文件package com.v512;import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.SimpleEmail;public class SendMailServlet extends HttpServlet { private static final long serialVersionUID = -9201649826567946642L;
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request, response); }
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
SimpleEmail email = new SimpleEmail();
email.setHostName("smtp.sina.com");
email.setAuthentication("web08", "web2008");
email.setCharset("UTF-8");
try {
email.setFrom(request.getParameter("from"));
email.addTo(request.getParameter("to"));
email.setSubject(request.getParameter("subject"));
email.setMsg(request.getParameter("content"));
email.send();
request.setAttribute("sendmail.message", "邮件发送成功!");
} catch (EmailException e) {
e.printStackTrace();
request.setAttribute("sendmail.message", "邮件发送不成功!");
}
request.getRequestDispatcher("/sendResult.jsp").forward(request,
response);
}}
<%@ page pageEncoding="UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>sendMeil.jsp 文件
<body>
<p align="center">发送邮件的程序</p>
<form id="form1" name="form1" method="post" action="<%=request.getContextPath()%>/servlet/sendMail">
  <table width="516" height="253" border="0" align="center">
    <tr>
      <td>收件人:</td>
      <td><label>
        <input type="text" name="to" id="to" />
      </label></td>
    </tr>
    <tr>
      <td>发件人:</td>
      <td><label>
        <input type="text" name="from" id="from" />
      </label></td>
    </tr>
    <tr>
      <td>主题:</td>
      <td><label>
        <input type="text" name="subject" id="subject" />
      </label></td>
    </tr>
    <tr>
      <td>内容:</td>
      <td><label>
        <textarea name="content" id="content" cols="45" rows="8"></textarea>
      </label></td>
    </tr>
    <tr>
      <td><label>
        <input type="submit" name="button" id="button" value="提交" />
      </label></td>
      <td><label>
        <input type="reset" name="button2" id="button2" value="重置" />
      </label></td>
    </tr>
  </table>
</form>
<p align="center">&nbsp;</p>
<p>&nbsp; </p>
</body></html>sendResult.jsp文件<%@ page language="java"  pageEncoding="UTF-8"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
       
    <title>display upload result</title>
    
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">    
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->  </head>
  
  <body> 
    <center>
    <p> ${requestScope['sendmail.message'] }</p>
    </center>
  </body>
</html>
在运行时出错,希望大虾们指教
错误提示如下:2009-5-20 9:31:32 org.apache.catalina.core.StandardWrapperValve invoke
严重: Allocate exception for servlet SendMailServlet
java.lang.UnsupportedClassVersionError: Bad version number in .class file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1847)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:873)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1326)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1205)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1068)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:791)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:127)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
at java.lang.Thread.run(Thread.java:595)