KickJava   Java API By Example, From Geeks To Geeks.

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


1 package edu.rice.rubis.beans.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  * @author <a HREF="mailto:cecchet@rice.edu">Emmanuel Cecchet</a> and <a HREF="mailto:julie.marguerite@inrialpes.fr">Julie Marguerite</a>
19  * @version 1.0
20  */

21
22
23 public class PutCommentAuth extends HttpServlet JavaDoc
24 {
25   
26   /**
27    * Describe <code>doGet</code> method here.
28    *
29    * @param request a <code>HttpServletRequest</code> value
30    * @param response a <code>HttpServletResponse</code> value
31    * @exception IOException if an error occurs
32    * @exception ServletException if an error occurs
33    */

34   public void doGet(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response) throws IOException JavaDoc, ServletException JavaDoc
35   {
36     ServletPrinter sp = null;
37     sp = new ServletPrinter(response, "PubCommentAuth");
38     
39     String JavaDoc to = request.getParameter("to");
40     String JavaDoc item = request.getParameter("itemId");
41     if ((to == null) || (to.equals("")) || (item == null) || (item.equals("")))
42     {
43       sp.printHTMLheader("RUBiS ERROR: Authentification for comment");
44       sp.printHTML("No item or user identifier received - Cannot process the request<br>");
45       sp.printHTMLfooter();
46       return ;
47     }
48
49     sp.printHTMLheader("RUBiS: User authentification for comment");
50     sp.printFile(Config.HTMLFilesPath+"/put_comment_auth_header.html");
51     sp.printHTML("<input type=hidden name=\"to\" value=\""+to+"\">");
52     sp.printHTML("<input type=hidden name=\"itemId\" value=\""+item+"\">");
53     sp.printFile(Config.HTMLFilesPath+"/auth_footer.html");
54     sp.printHTMLfooter();
55   }
56
57   /**
58    * Call the <code>doGet</code> method.
59    *
60    * @param request a <code>HttpServletRequest</code> value
61    * @param response a <code>HttpServletResponse</code> value
62    * @exception IOException if an error occurs
63    * @exception ServletException if an error occurs
64    */

65   public void doPost(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response) throws IOException JavaDoc, ServletException JavaDoc
66   {
67     doGet(request, response);
68   }
69 }
70
Popular Tags