01: package forum;
02:
03: import java.io.*;
04: import javax.servlet.*;
05: import javax.servlet.http.*;
06: import java.sql.*;
07: import java.sql.Connection;
08: import java.sql.Statement;
09: import java.sql.ResultSet;
10:
11: public class AddReply extends HttpServlet {
12:
13: DBConnectie db = new DBConnectie(Variable.getDb(), Variable
14: .getDbLogin(), Variable.getDbPassword());
15:
16: public void doPost(HttpServletRequest request,
17: HttpServletResponse response) throws ServletException,
18: IOException {
19: PrintWriter out = response.getWriter();
20: try {
21: String start = request.getParameter("start");
22: String forum_id = request.getParameter("forum_id");
23: int lastReply_id = Integer.parseInt(request
24: .getParameter("lastReply_id"));
25: String reply_id = Integer.toString(lastReply_id + 1);
26:
27: String thread_id = request.getParameter("thread_id");
28: String message = request.getParameter("message");
29: message = Filter.filterAll(message);
30:
31: String user = request.getParameter("user");
32:
33: db.connect();
34:
35: db
36: .query("INSERT INTO forum_message(forum_id,thread_id,reply_id,message,user,date_time) "
37: + "VALUES(\""
38: + forum_id
39: + "\",\""
40: + thread_id
41: + "\",\""
42: + reply_id
43: + "\",\""
44: + message
45: + "\",\""
46: + user
47: + "\",SYSDATE())");
48:
49: db.close();
50:
51: response.sendRedirect(Variable.getForumPath()
52: + "index.jsp?page=message&forum_id=" + forum_id
53: + "&thread_id=" + thread_id + "&start=" + start);
54:
55: } catch (Exception e) {
56: out.println(e);
57: }
58:
59: }
60:
61: public void doGet(HttpServletRequest request,
62: HttpServletResponse response) throws ServletException,
63: IOException {
64: doPost(request, response);
65: }
66:
67: }
|