KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > compiere > wstore > CheckOutServlet


1 /******************************************************************************
2  * The contents of this file are subject to the Compiere License Version 1.1
3  * ("License"); You may not use this file except in compliance with the License
4  * You may obtain a copy of the License at http://www.compiere.org/license.html
5  * Software distributed under the License is distributed on an "AS IS" basis,
6  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
7  * the specific language governing rights and limitations under the License.
8  * The Original Code is Compiere ERP & CRM Smart Business Solution
9  * The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
10  * Portions created by Jorg Janke are Copyright (C) 1999-2003 Jorg Janke, parts
11  * created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
12  * Contributor(s): ______________________________________.
13  *****************************************************************************/

14 package org.compiere.wstore;
15
16 import javax.servlet.*;
17 import javax.servlet.http.*;
18 import java.io.*;
19 import java.util.*;
20 import java.sql.*;
21
22 import org.apache.ecs.*;
23 import org.apache.ecs.xhtml.*;
24
25 import org.compiere.util.*;
26 import org.compiere.www.*;
27
28
29 /**
30  * Check Out.
31  *
32  * @author Jorg Janke
33  * @version $Id: CheckOutServlet.java,v 1.8 2003/10/04 03:58:26 jjanke Exp $
34  */

35 public class CheckOutServlet extends HttpServlet
36 {
37     /** Logging */
38     private Logger log = Logger.getCLogger(getClass());
39     /** Name */
40     static public final String JavaDoc NAME = "checkOutServlet";
41     /** Attribute */
42     static public final String JavaDoc ATTR_CHECKOUT = "CheckOut";
43
44     /**
45      * Initialize global variables
46      *
47      * @param config Configuration
48      * @throws ServletException
49      */

50     public void init(ServletConfig config)
51         throws ServletException
52     {
53         super.init(config);
54         if (!WEnv.initWeb(config))
55             throw new ServletException("CheckOutServlet.init");
56     } // init
57

58     /**
59      * Get Servlet information
60      * @return Info
61      */

62     public String JavaDoc getServletInfo()
63     {
64         return "Compiere Web CheckOut Servlet";
65     } // getServletInfo
66

67     /**
68      * Clean up resources
69      */

70     public void destroy()
71     {
72         log.debug("destroy");
73     } // destroy
74

75
76     /**
77      * Process the HTTP Get request.
78      * (logout, deleteCookie)
79      * Sends Web Request Page
80      *
81      * @param request request
82      * @param response response
83      * @throws ServletException
84      * @throws IOException
85      */

86     public void doGet(HttpServletRequest request, HttpServletResponse response)
87         throws ServletException, IOException
88     {
89         log.info("doGet from " + request.getRemoteHost() + " - " + request.getRemoteAddr());
90         HttpSession session = request.getSession(true);
91         session.removeAttribute(JSPEnv.HDR_MESSAGE);
92
93         // Web User/Basket
94
WebUser wu = (WebUser)session.getAttribute(WebUser.NAME);
95         WebBasket wb = (WebBasket)session.getAttribute(WebBasket.NAME);
96
97         String JavaDoc url = "login.jsp";
98         // Nothing in basket
99
if (wb == null || wb.getLineCount() == 0)
100             url = "basket.jsp";
101         else
102         {
103             session.setAttribute(ATTR_CHECKOUT, "Y"); // indicate checkout
104
if (wu != null && wu.isLoggedIn ())
105                 url = "addressInfo.jsp";
106         }
107
108     // if (request.isSecure())
109
// {
110
log.info ("doGet - Forward to " + url);
111             RequestDispatcher dispatcher = getServletContext ().getRequestDispatcher (url);
112             dispatcher.forward (request, response);
113     // }
114
// else
115
// Switch to secure
116
// {
117
// url = "https://" + request.getServerName() + request.getContextPath() + "/" + url;
118
// log.info ("doGet - Secure Forward to " + url);
119
// WUtil.createForwardPage(response, "Secure Access", url);
120
// }
121
} // doGet
122

123     /**
124      * Process the HTTP Post request
125      *
126      * @param request request
127      * @param response response
128      * @throws ServletException
129      * @throws IOException
130      */

131     public void doPost(HttpServletRequest request, HttpServletResponse response)
132         throws ServletException, IOException
133     {
134         log.info("doPost from " + request.getRemoteHost() + " - " + request.getRemoteAddr());
135         HttpSession session = request.getSession(false);
136     } // doPost
137

138 } // CheckOutServlet
139
Popular Tags