KickJava   Java API By Example, From Geeks To Geeks.

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


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 buy an item at the "buy now" price.
12  * It must be called this way :
13  * <pre>
14  * http://..../BuyNowAuth?itemId=xx where xx is the id of the item
15  * </pre>
16  * @author <a HREF="mailto:cecchet@rice.edu">Emmanuel Cecchet</a> and <a HREF="mailto:julie.marguerite@inrialpes.fr">Julie Marguerite</a>
17  * @version 1.0
18  */

19
20
21 public class BuyNowAuth extends HttpServlet JavaDoc
22 {
23
24   /**
25    * Display the web page with the form to authenticate the user
26    * @param request a <code>HttpServletRequest</code> value
27    * @param response a <code>HttpServletResponse</code> value
28    * @exception IOException if an error occurs
29    * @exception ServletException if an error occurs
30    */

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

59   public void doPost(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response) throws IOException JavaDoc, ServletException JavaDoc
60   {
61     doGet(request, response);
62   }
63 }
64
Popular Tags