KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > edu > rice > rubis > servlets > PutCommentAuth


1 package edu.rice.rubis.servlets;
2
3 import java.io.IOException JavaDoc;
4
5 import javax.servlet.ServletException JavaDoc;
6 import javax.servlet.http.HttpServlet JavaDoc;
7 import javax.servlet.http.HttpServletRequest JavaDoc;
8 import javax.servlet.http.HttpServletResponse JavaDoc;
9
10 /** This servlets display the page authentifying the user
11  * to allow him to put a comment on another user.
12  * It must be called this way :
13  * <pre>
14  * http://..../PutCommentAuth?to=xx&itemId=yy
15  * where xx is the id of the user that will receive the comment
16  * yy is the item id to which this comment is related to
17  * /<pre>
18  */

19
20 public class PutCommentAuth extends HttpServlet JavaDoc
21 {
22
23
24   public void doGet(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response)
25     throws IOException JavaDoc, ServletException JavaDoc
26   {
27     ServletPrinter sp = null;
28     sp = new ServletPrinter(response, "PubCommentAuth");
29
30     String JavaDoc to = request.getParameter("to");
31     String JavaDoc item = request.getParameter("itemId");
32     if ((to == null) || (to.equals("")) || (item == null) || (item.equals("")))
33     {
34       sp.printHTMLheader("RUBiS ERROR: Authentification for comment");
35       sp.printHTML(
36         "No item or user identifier received - Cannot process the request<br>");
37       sp.printHTMLfooter();
38       return;
39     }
40
41     sp.printHTMLheader("RUBiS: User authentification for comment");
42     sp.printFile(Config.HTMLFilesPath + "/put_comment_auth_header.html");
43     sp.printHTML("<input type=hidden name=\"to\" value=\"" + to + "\">");
44     sp.printHTML("<input type=hidden name=\"itemId\" value=\"" + item + "\">");
45     sp.printFile(Config.HTMLFilesPath + "/auth_footer.html");
46     sp.printHTMLfooter();
47   }
48
49   public void doPost(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response)
50     throws IOException JavaDoc, ServletException JavaDoc
51   {
52     doGet(request, response);
53   }
54 }
55
Popular Tags