代码是这样的:
<%@ page contentType= "text/html;charset=gb2312 " %>
<%@ page import= "javax.mail.* " %>
<%@ page import= "javax.mail.internet.* " %>
<%@ page import= "java.util.* " %>
<%@ page import= "javax.activation.* " %>
<html>
<head>
<title> 发送邮件 </title>
</head>
<body>
<%
try{
Properties pro=new Properties();
Session sendmailsession;
Transport transport;
sendmailsession=Session.getInstance(pro,null);
pro.put( "mail.smtp.host ", "smtp.126.com ");
Message m=new MimeMessage(sendmailsession);
m.setFrom(new InternetAddress(request.getParameter( "from ")));
m.setRecipient(Message.RecipientType.TO,new InternetAddress(request.getParameter( "to ")));
m.setSubject(request.getParameter( "subject "));
m.setSentDate(new Date());
m.setText(request.getParameter( "content "));
transport=sendmailsession.getTransport( "smtp ");
transport.send(m);
%>
<p> 邮件已经发送成功 </p>
<%
}catch(Exception ex){
out.println(ex.toString());
}
%>
</body>
</html>
不知道为何会错误
错误信息是:
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 12 in the jsp file: /sendmail.jsp