1 24 25 package edu.rice.rubbos.servlets; 26 27 import java.io.IOException ; 28 import java.sql.Connection ; 29 import java.sql.PreparedStatement ; 30 31 import javax.servlet.ServletException ; 32 import javax.servlet.http.HttpServletRequest ; 33 import javax.servlet.http.HttpServletResponse ; 34 35 public class PostComment extends RubbosHttpServlet 36 { 37 38 public int getPoolSize() 39 { 40 return Config.BrowseCategoriesPoolSize; 41 } 42 43 private void closeConnection(PreparedStatement stmt, Connection conn) 44 { 45 try 46 { 47 if (stmt != null) 48 stmt.close(); } 50 catch (Exception ignore) 51 { 52 } 53 54 try 55 { 56 if (conn != null) 57 releaseConnection(conn); 58 } 59 catch (Exception ignore) 60 { 61 } 62 } 63 64 65 public void doGet(HttpServletRequest request, HttpServletResponse response) 66 throws IOException , ServletException 67 { 68 69 ServletPrinter sp = null; 70 71 sp = new ServletPrinter(response, "BrowseCategoriesByCategory"); 72 73 String storyIdtest, categoryId, testparent, comment_table; 74 int parent = 0, storyId = 0; 75 76 storyIdtest = request.getParameter("storyId"); 77 testparent = request.getParameter("parent"); 78 79 if (storyIdtest != null) 80 { 81 storyId = (Integer.valueOf(request.getParameter("storyId"))).intValue(); 82 } 83 84 if (testparent != null) 85 { 86 parent = (Integer.valueOf(request.getParameter("parent"))).intValue(); 87 } 88 89 comment_table = request.getParameter("comment_table"); 90 91 if (comment_table == null) 92 { 93 sp.printHTML("Viewing comment, You must provide a comment table!<br>"); 94 return; 95 } 96 97 sp.printHTMLheader("RUBBoS: Comment submission"); 98 sp 99 .printHTML("<p><br><center><h2>Post a comment !</h2><br>\n" 100 + "<form action=\"/rubbos/servlet/edu.rice.rubbos.servlets.StoreComment\" method=POST>\n" 101 + "<input type=hidden name=storyId value=" 102 + storyId 103 + ">\n" 104 + "<input type=hidden name=parent value=" 105 + parent 106 + ">\n" 107 + "<input type=hidden name=comment_table value=" 108 + comment_table 109 + ">\n" 110 + "<center><table>\n" 111 + "<tr><td><b>Nickname</b><td><input type=text size=20 name=nickname>\n" 112 + "<tr><td><b>Password</b><td><input type=text size=20 name=password>\n" 113 + "<tr><td><b>Subject</b><td><input type=text size=100 name=subject>\n" 114 + "</SELECT></table><p><br>\n" 115 + "<TEXTAREA rows=\"20\" cols=\"80\" name=\"body\">Write your comment here</TEXTAREA><br><p>\n" 116 + "<input type=submit value=\"Post your comment now!\"></center><p>\n"); 117 118 sp.printHTMLfooter(); 119 120 } 121 122 public void doPost(HttpServletRequest request, HttpServletResponse response) 123 throws IOException , ServletException 124 { 125 doGet(request, response); 126 } 127 128 } 129 | Popular Tags |