H
hongma
Unregistered / Unconfirmed
GUEST, unregistred user!
我的配置为apache2.0 + resin2.1.9;文件名为send.
jsp;原码如下:
<%@ page contentType = "text/html;
charset = gb2312" %>
<html>
<head>
<meta http-equiv = "Content-Type" content = "text/html;
charset = gb2312">
<title> 意见箱 </title>
<style type = "text/css">
<!--
@import "css/jsp.css"
-->
</style>
</head>
<body bgcolor = "#ffccff">
<%@ page import = "java.io.*" %>
<%@ page import = "java.net.*" %>
<%@ page import = "java.util.*" %>
<%
//与主机通讯发送Email的类
class Parameters{
Socket socket;
PrintWriter mailOut;
BufferedReader mailIn;
[red] } //出错的地方red]
//发送命令到主机的方法
[red]void sendCommand(Parameters parms, String cmd) throws IOException {//出错的地方[/red]
parms.mailOut.print(cmd + "/r/n");
parms.mailOut.flush();
String line = parms.mailIn.readLine();
}
//发送数据到主机的方法
void sendData(
Parameters parms,
String to,
String subject,
String message
) throws IOException {
message = "to:" + to + "/r/n" + message;
message = "subject:" + subject + "/r/n" + message;
parms.mailOut.print(message + "/r/n");
parms.mailOut.print("/r/n /r/n");
parms.mailOut.flush();
}
//获取表单参数
String host = "smpt.163.com";
String from = request.getParameter("mail");
String subject = request.getParameter("title");
String message = request.getParameter("content");
String name = request.getParameter("name");
[red]message = "留言人:" + name + "/r/n" + message;//出错的地方[/red]
String to = "yuebao@163.com"
//打开端口与邮件主机通讯
Parameters parms = new Parameters();
parms.socket = new Socket(host, 25);
parms.mailOut = new PrintWriter(parms.socket.getOutputStream(), true);
parms.mailIn = new BufferedReader(new InputStreamRead(parms.socket.getInputStream()))
sendCommand(parms, "HELO" + host);
sendCommand(parms, "Mail from:" + from);
sendCommand(parms, "Rept to:" + to);
sendData(parms, to, subject, message);
parms.socket.close();
%> <br>
<%=name%>先生(小姐):<br>
您好!您的意见已经发送到站长信息。<br>
感谢您为我们提出了宝贵的意见!
</body>
</html>
打入http://localhost:8080/src/jsp/send.
jsp后提示如下信息:
[h1]500 Servlet Exception[/h1]
Note: sun.tools.javac.Main has been deprecated.
/src/jsp/send.
jsp:23: '}' expected.
}
^
/src/jsp/send.
jsp:26: Statement expected.
void sendCommand(Parameters parms, String cmd) throws IOException {
^
/src/jsp/send.
jsp:52: Identifier expected.
message = "/u7559/u8a00/u4eba/uff1a" + name + "/r/n" + message;
^
3 errors, 1 warning
--------------------------------------------------------------------------------
Resin 2.1.9 (built Tue Apr 15 14:28:40 PDT 2003)
jsp;原码如下:
<%@ page contentType = "text/html;
charset = gb2312" %>
<html>
<head>
<meta http-equiv = "Content-Type" content = "text/html;
charset = gb2312">
<title> 意见箱 </title>
<style type = "text/css">
<!--
@import "css/jsp.css"
-->
</style>
</head>
<body bgcolor = "#ffccff">
<%@ page import = "java.io.*" %>
<%@ page import = "java.net.*" %>
<%@ page import = "java.util.*" %>
<%
//与主机通讯发送Email的类
class Parameters{
Socket socket;
PrintWriter mailOut;
BufferedReader mailIn;
[red] } //出错的地方red]
//发送命令到主机的方法
[red]void sendCommand(Parameters parms, String cmd) throws IOException {//出错的地方[/red]
parms.mailOut.print(cmd + "/r/n");
parms.mailOut.flush();
String line = parms.mailIn.readLine();
}
//发送数据到主机的方法
void sendData(
Parameters parms,
String to,
String subject,
String message
) throws IOException {
message = "to:" + to + "/r/n" + message;
message = "subject:" + subject + "/r/n" + message;
parms.mailOut.print(message + "/r/n");
parms.mailOut.print("/r/n /r/n");
parms.mailOut.flush();
}
//获取表单参数
String host = "smpt.163.com";
String from = request.getParameter("mail");
String subject = request.getParameter("title");
String message = request.getParameter("content");
String name = request.getParameter("name");
[red]message = "留言人:" + name + "/r/n" + message;//出错的地方[/red]
String to = "yuebao@163.com"
//打开端口与邮件主机通讯
Parameters parms = new Parameters();
parms.socket = new Socket(host, 25);
parms.mailOut = new PrintWriter(parms.socket.getOutputStream(), true);
parms.mailIn = new BufferedReader(new InputStreamRead(parms.socket.getInputStream()))
sendCommand(parms, "HELO" + host);
sendCommand(parms, "Mail from:" + from);
sendCommand(parms, "Rept to:" + to);
sendData(parms, to, subject, message);
parms.socket.close();
%> <br>
<%=name%>先生(小姐):<br>
您好!您的意见已经发送到站长信息。<br>
感谢您为我们提出了宝贵的意见!
</body>
</html>
打入http://localhost:8080/src/jsp/send.
jsp后提示如下信息:
[h1]500 Servlet Exception[/h1]
Note: sun.tools.javac.Main has been deprecated.
/src/jsp/send.
jsp:23: '}' expected.
}
^
/src/jsp/send.
jsp:26: Statement expected.
void sendCommand(Parameters parms, String cmd) throws IOException {
^
/src/jsp/send.
jsp:52: Identifier expected.
message = "/u7559/u8a00/u4eba/uff1a" + name + "/r/n" + message;
^
3 errors, 1 warning
--------------------------------------------------------------------------------
Resin 2.1.9 (built Tue Apr 15 14:28:40 PDT 2003)