1 6 7 package com.quikj.application.web.talk.jspbeans; 8 9 import java.io.*; 10 import javax.servlet.*; 11 import javax.servlet.http.*; 12 13 17 public class ContactCenterUserInfoServlet extends HttpServlet 18 { 19 21 public void init(ServletConfig config) throws ServletException 22 { 23 super.init(config); 24 } 25 26 28 public void destroy() 29 { 30 } 31 32 36 protected void processRequest(HttpServletRequest request, HttpServletResponse response) 37 throws ServletException, IOException 38 { 39 String customer = request.getParameter("customer"); 40 if (customer == null) 41 { 42 request.setAttribute("errorMessage", 43 "talk.servlet.no.customer"); 44 goToPage("/aceapp/jsp/contactcenter/talk_internal_error.jsp", request, response); 45 return; 46 } 47 48 ContactCenterCustomerList customer_bean = (ContactCenterCustomerList)getServletContext().getAttribute( 49 ContactCenterServlet.CUSTOMER_BEAN); 50 if (customer_bean == null) 51 { 52 request.setAttribute("errorMessage", 53 "talk.servlet.uninitialized"); 54 goToPage( "/aceapp/jsp/contactcenter/talk_internal_error.jsp", request, response); 55 return; 56 } 57 58 try 59 { 60 ContactCenterCustomerProperty customer_property = 62 customer_bean.getCustomerProperty(customer); 63 64 if (customer_property == null) 65 { 66 request.setAttribute("errorMessage", 68 "talk.servlet.customer.undefined"); 69 goToPage("/aceapp/jsp/contactcenter/talk_internal_error.jsp", request, response); 70 return; 71 } 72 73 request.setAttribute("customerProperty", customer_property); 75 76 ContactCenterUnrestrictedAccessForm form_bean = new ContactCenterUnrestrictedAccessForm(); 78 form_bean.populate(request); 79 request.setAttribute("formBean", form_bean); 80 81 if(form_bean.isFormError() == true) 83 { 84 request.setAttribute( "errorMessage", "talk.unrestricted.enter.mandatory"); 85 86 String page = (String )customer_property.getPagesParams().get("userInfoPage"); 87 if (page == null) 88 { 89 page = "/aceapp/jsp/contactcenter/talk_unrestricted_userinfo.jsp"; 90 } 91 goToPage(page, request, response ); 92 return; 93 } 94 95 if (customer_property.getClientType().equals("JAVA") == true) 96 { 97 String page = (String )customer_property.getPagesParams().get("chatButtonPage"); 98 if (page == null) 99 { 100 page = "/aceapp/jsp/contactcenter/talk_display_applet.jsp"; 101 } 102 goToPage(page, request, response ); 103 } 104 else if (customer_property.getClientType().equals("HTML") == true) 105 { 106 String page = (String )customer_property.getPagesParams().get("chatPage"); 107 if (page == null) 108 { 109 page = "/aceapp/jsp/contactcenter/talk_display_chat.jsp"; 110 } 111 goToPage(page, request, response ); 112 } 113 return; 114 } 115 catch (Exception ex) 116 { 117 request.setAttribute ("exceptionMessage", 118 ex.getClass().getName() + ": " 119 + ex.getMessage()); 120 goToPage( "/aceapp/jsp/contactcenter/talk_internal_error.jsp", request, response); 121 return; 122 } 123 124 } 125 126 130 protected void doGet(HttpServletRequest request, HttpServletResponse response) 131 throws ServletException, IOException 132 { 133 134 processRequest(request, response); 135 136 } 137 138 142 protected void doPost(HttpServletRequest request, HttpServletResponse response) 143 throws ServletException, IOException 144 { 145 146 processRequest(request, response); 147 148 } 149 150 153 public String getServletInfo() 154 { 155 return servletDescription; 156 } 157 158 163 private void goToPage( String address, 164 HttpServletRequest request, 165 HttpServletResponse response ) 166 throws ServletException, IOException 167 { 168 169 RequestDispatcher dispatcher = 170 getServletContext().getRequestDispatcher( address ); 171 dispatcher.forward( request, response ); 172 173 } 174 175 179 private String servletDescription = 180 "This servlet verifies if the " 181 + "customer entered in the required input and accrodingly " 182 + "either forwards the customer to the applet/chat page or back to the JSP"; 183 184 } 185 | Popular Tags |