KickJava   Java API By Example, From Geeks To Geeks.

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


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 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 public class BuyNowAuth extends HttpServlet JavaDoc
21 {
22
23
24   /** Display the web page with the form to authenticate the user */
25   public void doGet(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response)
26     throws IOException JavaDoc, ServletException JavaDoc
27   {
28     ServletPrinter sp = null;
29     sp = new ServletPrinter(response, "BuyNowAuth");
30
31     String JavaDoc value = request.getParameter("itemId");
32     if ((value == null) || (value.equals("")))
33     {
34       sp.printHTMLheader("RUBiS ERROR: Authentification for buying an item");
35       sp.printHTML(
36         "No item identifier received - Cannot process the request<br>");
37       sp.printHTMLfooter();
38       return;
39     }
40
41     sp.printHTMLheader("RUBiS: User authentification for buying an item");
42     sp.printFile(Config.HTMLFilesPath + "/buy_now_auth_header.html");
43     sp.printHTML("<input type=hidden name=\"itemId\" value=\"" + value + "\">");
44     sp.printFile(Config.HTMLFilesPath + "/auth_footer.html");
45     sp.printHTMLfooter();
46   }
47
48   /** Call the doGet method*/
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