/** * This calls the itemselection.jsp and list all items available for a WorkOrder and a WorkOrder's * item list * * @param workorderid - the WO_ID of the parent WorkOrder * @param request - servlet request * @param response - servlet response */ private void listProducts( long workorderId, WorkOrderDetailRemote workorderdetEJBean, HttpSession session, HttpServletRequest req, HttpServletResponse resp) { try { // If any product object is left over in session remove it session.removeValue("itemObj"); // Create db connection for EJB workorderdetEJBean.connect(); // Get the 2D Array which has the List of Items for the WorkOrder // grouped by the Billing System. Object[][] productList = workorderdetEJBean.getWorkOrderItems(workorderId); // Get the WorkOrder Object WorkOrder workorderObj = workorderdetEJBean.getWorkOrderInfo(workorderId); // Get the List of all Product Names for the WorkOrder String[] productNameList = workorderdetEJBean.getProdList(workorderId); for (int w = 0; w < productNameList.length; w++) USFEnv.getLog() .writeDebug("VALUES INSIDE productNameList is" + productNameList[w], this, null); // Set the attributes to the itemselection JSP req.setAttribute("productNameList", productNameList); req.setAttribute("productList", productList); req.setAttribute("workorderObj", workorderObj); // Release db connection for EJB workorderdetEJBean.release(); // Include the JSP includeJSP(req, resp, ITEM_JSP_PATH, "itemselection"); return; } catch (Exception e) { String errorMsg = "Fail to list products for a WORKORDER " + workorderId; USFEnv.getLog().writeCrit(errorMsg, this, e); errorJSP(req, resp, errorMsg); } }
public void _jspService(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException { PageContext pageContext = null; HttpSession session = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page = this; JspWriter _jspx_out = null; PageContext _jspx_page_context = null; try { response.setContentType("text/html"); pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true); _jspx_page_context = pageContext; application = pageContext.getServletContext(); config = pageContext.getServletConfig(); session = pageContext.getSession(); out = pageContext.getOut(); _jspx_out = out; out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("<!--%@ page errorPage=\"/error.jsp\" %-->\n"); response.setHeader("Pragma", "no-cache"); // HTTP 1.0 response.setDateHeader("Expires", 0); response.setHeader("Cache-Control", "no-cache"); // HTTP 1.1 String _adminid = ""; String _adminname = ""; String _admintype = ""; String _admingroup = ""; String _approval = ""; String _adminclass = ""; String _adminmail = ""; try { _adminid = (String) session.getAttribute("adminid"); if (_adminid == null || _adminid.length() == 0 || _adminid.equals("null")) { response.sendRedirect("/admin/login_first.html"); return; } _adminname = (String) session.getAttribute("adminname"); _admintype = (String) session.getAttribute("admintype"); _admingroup = (String) session.getAttribute("admingroup"); _approval = (String) session.getAttribute("approval"); _adminclass = (String) session.getAttribute("adminclass"); _adminmail = (String) session.getAttribute("admin_email"); // session.setMaxInactiveInterval(60*60); } catch (Exception e) { response.sendRedirect("/admin/login_first.html"); return; } out.write('\n'); out.write('\n'); out.write('\n'); String password = request.getParameter("password"); String fromURL = request.getParameter("fromURL"); String oldPassword = ""; String sql = ""; int iCnt = 0; boolean isSucceeded = false; String strMsg = ""; Connection conn = null; MatrixDataSet matrix = null; DataProcess dataProcess = null; PreparedStatement pstmt = null; String targetUrl = ""; try { if (password.equals("1111")) { throw new UserDefinedException( "The new password is not acceptable. Change your password."); } Context ic = new InitialContext(); DataSource ds = (DataSource) ic.lookup("java:comp/env/jdbc/scm"); conn = ds.getConnection(); matrix = new dbconn.MatrixDataSet(); dataProcess = new DataProcess(); sql = " select password " + " from admin_01t " + " where adminid = '" + _adminid + "' "; iCnt = dataProcess.RetrieveData(sql, matrix, conn); if (iCnt > 0) { oldPassword = matrix.getRowData(0).getData(0); } else { throw new UserDefinedException("Can't find User Information."); } if (password.equals(oldPassword)) { throw new UserDefinedException( "The new password is not acceptable. Change your password."); } // update ó¸®... int idx = 0; conn.setAutoCommit(false); sql = " update admin_01t " + " set password = ?, pw_date = sysdate() " + " where adminid = ? "; pstmt = conn.prepareStatement(sql); pstmt.setString(++idx, password); pstmt.setString(++idx, _adminid); iCnt = pstmt.executeUpdate(); if (iCnt != 1) { throw new UserDefinedException("Password update failed."); } conn.commit(); isSucceeded = true; } catch (UserDefinedException ue) { try { conn.rollback(); } catch (Exception ex) { } strMsg = ue.getMessage(); } catch (Exception e) { try { conn.rollback(); } catch (Exception ex) { } System.out.println("Exception /admin/resetAdminPasswd : " + e.getMessage()); throw e; } finally { if (pstmt != null) { try { pstmt.close(); } catch (Exception e) { } } if (conn != null) { try { conn.setAutoCommit(true); } catch (Exception e) { } conn.close(); } } // °á°ú ¸Þ½ÃÁö ó¸® if (isSucceeded) { // where to go? if (fromURL.equals("menu")) { targetUrl = ""; } else { targetUrl = "/admin/index2.jsp"; } strMsg = "The data are successfully processed."; } else { strMsg = "The operation failed.\\n" + strMsg; targetUrl = "/admin/resetAdminPasswdForm.jsp"; } out.write("\n"); out.write("<html>\n"); out.write("<head>\n"); out.write("<title></title>\n"); out.write("<link href=\"/common/css/style.css\" rel=\"stylesheet\" type=\"text/css\">\n"); out.write("</head>\n"); out.write("<body leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'>\n"); out.write("<form name=\"form1\" method=\"post\" action=\""); out.print(targetUrl); out.write("\">\n"); out.write("<input type='hidden' name='fromURL' value='"); out.print(fromURL); out.write("'>\n"); out.write("</form>\n"); out.write("<script language=\"javascript\">\n"); if (targetUrl.length() > 0) { out.write("\n"); out.write(" alert('"); out.print(strMsg); out.write("');\n"); out.write(" document.form1.submit();\n"); } out.write("\n"); out.write("</script>\n"); out.write("<table width='840' border='0' cellspacing='0' cellpadding='0'><tr><td>\n"); out.write("\n"); out.write("<table width='99%' border='0' cellspacing='0' cellpadding='0'>\n"); out.write("<tr>\n"); out.write(" <td height='15' colspan='2'></td>\n"); out.write("</tr>\n"); out.write("<tr>\n"); out.write(" <td width='3%'><img src='/img/title_icon.gif'></td>\n"); out.write(" <td width='*' class='left_title'>Password Change</td>\n"); out.write("</tr>\n"); out.write("<tr>\n"); out.write(" <td width='100%' height='2' colspan='2'><hr width='100%'></td>\n"); out.write("</tr>\n"); out.write("<tr>\n"); out.write(" <td height='10' colspan='2'></td>\n"); out.write("</tr>\n"); out.write("</table>\n"); out.write("\n"); out.write("<table width='90%' border='0' cellspacing='0' cellpadding='0' align='center'>\n"); out.write("<tr>\n"); out.write(" <td width='100%' align='center'><img border=\"0\" src=\"/img/pass.jpg\">\n"); out.write(" <br><br>\n"); out.write(" <b>The Password has been changed successfully.</b></td>\n"); out.write("</tr>\n"); out.write("</table>\n"); out.println(CopyRightLogo()); out.write("\n"); out.write("</tr></td></table>\n"); out.write("</body>\n"); out.write("</html>"); } catch (Throwable t) { if (!(t instanceof SkipPageException)) { out = _jspx_out; if (out != null && out.getBufferSize() != 0) try { out.clearBuffer(); } catch (java.io.IOException e) { } if (_jspx_page_context != null) _jspx_page_context.handlePageException(t); } } finally { _jspxFactory.releasePageContext(_jspx_page_context); } }
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { server svr = new server(); response.setContentType("text/html"); HttpSession session = request.getSession(true); PrintWriter out = response.getWriter(); String email = request.getParameter("email"); String pw1 = request.getParameter("pw1"); String pw2 = request.getParameter("pw2"); String error = null; String username = session.getAttribute("username").toString(); if (pw1.compareTo(pw2) != 0) { error = "Passwords do not match"; session.setAttribute("ErrorMessage", error); response.sendRedirect("home.jsp"); } try { Statement st = null; String strQuery = null; if ((pw1.length() == 0) && (email.length() == 0)) { session.setAttribute("ErrorMessage", "Nothing to change!"); response.sendRedirect("home.jsp"); } else if ((pw1.length() != 0) && (email.length() != 0)) { strQuery = "UPDATE `twitter2012`.`users` SET `password`='" + pw1 + "', `email_address`='" + email + "' WHERE `username`='" + username + "'"; session.setAttribute("email", email); } else if ((pw1.length() == 0) && (email.length() != 0)) { strQuery = "UPDATE `twitter2012`.`users` SET `email_address`='" + email + "' WHERE `username`='" + username + "'"; session.setAttribute("email", email); } else if ((pw1.length() != 0) && (email.length() == 0)) { strQuery = "UPDATE `twitter2012`.`users` SET `password`='" + pw1 + "' WHERE `username`='" + username + "'"; } Connection dbcon = null; Class.forName("com.mysql.jdbc.Driver").newInstance(); dbcon = DriverManager.getConnection(svr.getURL(), svr.getUN(), svr.getPW()); st = dbcon.createStatement(); st.executeUpdate(strQuery); session.setAttribute("ErrorMessage", "Details Changed"); dbcon.close(); session.setAttribute("ErrorMessage", "Details Changed"); response.sendRedirect("home.jsp"); } catch (Exception ex) { out.println(ex); } }
/** * This is the main controller logic for item selection servlet. This determines whether to show a * list of items for a WorkOrder, add a item, edit a item's detail information, or delete a item. * The product_action parameter is past to this servlet to determine what action to perform. The * product_action parameter is a button defined by JSPs related to product presentation screens. * * <p>The default action is to show all product related to a parent WorkOrder. * * @param req HttpServlet request * @param resp HttpServlet response */ public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { WorkOrderDetailRemote workorderdetEJBean = null; securityChecks(req, resp); // Get the current session HttpSession session = req.getSession(false); if (session == null) return; String sTmp = ""; // Get a new business logic EJB (custInfoEJBean) USFEnv.getLog().writeDebug("getting buslogic EJB", this, null); try { workorderdetEJBean = workorderdetHome.create(); USFEnv.getLog().writeDebug("EJBean Created", this, null); } catch (CreateException e) { String errorMsg = "Critical Exception in ItemsServlet"; USFEnv.getLog().writeCrit(errorMsg + " failed EJB creation", this, e); errorJSP(req, resp, errorMsg); return; } catch (RemoteException e) { String errorMsg = "Critical Exception in ItemsServlet"; USFEnv.getLog().writeCrit(errorMsg + " failed EJB connect", this, e); errorJSP(req, resp, errorMsg); return; } catch (Exception e) { String errorMsg = "Critical Exception no EJB created"; USFEnv.getLog().writeCrit(errorMsg + " failed EJB creation", this, e); errorJSP(req, resp, errorMsg); return; } try { // Button user pressed in the itemselection.jsp String sJSPAction = req.getParameter("product_action"); USFEnv.getLog().writeWarn("product_action from JSP: " + sJSPAction, this, null); short year = Short.valueOf((String) session.getValue("Iyear")).shortValue(); long customerId = Long.valueOf((String) session.getValue("rcustId")).longValue(); long applicationId = Long.valueOf((String) session.getValue("rappid")).longValue(); long workorderId = 0; long bkId = 0; long billkeyId = 0; long bsId = 0; long wodId = 0; String editflag = ""; String bsNm = ""; java.sql.Date strtDate = null; java.sql.Date endDate = null; String prodError = ""; // Check to make sure session does have an WorkOrder ID if (session.getValue("WorkOrderId") != null) { // If Yes get the parent WorkOrder ID from session workorderId = Long.valueOf((String) session.getValue("WorkOrderId")).longValue(); } // Button Action from JSP is empty then show the Default page of the // Product Listing. if (USFUtil.isBlank(sJSPAction)) { USFEnv.getLog().writeDebug("Display product list for FRN.", this, null); // list items for parent Work Order Number Vector billingsystems = null; WrkOrdrDets workorderdets = new WrkOrdrDets(); billingsystems = workorderdets.getBillingSystems(); req.setAttribute("BillingSystems", billingsystems); for (int s = 0; s < billingsystems.size(); s++) USFEnv.getLog() .writeDebug("INSIDE BILLING SYSTEMS " + billingsystems.elementAt(s), this, null); listProducts(workorderId, workorderdetEJBean, session, req, resp); return; } // Button action from JSP is to Add a new Item else if (sJSPAction.equals("add")) { // Remove the Product Object from session session.removeValue("prodObj"); editflag = "addnew"; req.setAttribute("editflag", editflag); // Read the Item and the Billing System for adding the New // Item. String formProdBsId = (String) req.getParameter("formProdId"); String formProdId = formProdBsId.substring(0, formProdBsId.indexOf("|")); String formProdName = formProdBsId.substring(formProdBsId.indexOf("|") + 1); long rscId = (new Long(formProdId).longValue()); // bsId = (new Long( formBsId ).longValue()) ; String billSystem = formProdName.substring(0, formProdName.indexOf("-")); String itemName = formProdName.substring(formProdName.indexOf("-") + 1); BlgSys blgSys = new BlgSys(); bsId = blgSys.getBsId(billSystem); // Create db connection for EJB workorderdetEJBean.connect(); // Get the WorkOrder Object. WorkOrder woObj = workorderdetEJBean.getWorkOrderInfo(workorderId); // Get the list of Billing Keys for the Billing System. String[] blgKeys = workorderdetEJBean.getBillingKeys(customerId, bsId); // Release db connection for EJB workorderdetEJBean.release(); // If no Billing Keys for the Billing System selected then redirect // to the List Items screen and show the error Message. if (blgKeys == null) { BlgSys blgsys = new BlgSys(); Hashtable bSysList = (Hashtable) blgsys.searchBlgSys(); // Hashtable bSysList = (Hashtable) USFEnv.getBillSystems(); // Set the JSP error message req.setAttribute("errorMsg", "No BTNs for Billing System " + billSystem); // list products for parent WorkOrder Number listProducts(workorderId, workorderdetEJBean, session, req, resp); return; } req.setAttribute("prodcredit", "N"); req.setAttribute("bsystem", String.valueOf(bsId)); req.setAttribute("bkList", blgKeys); req.setAttribute("prodId", formProdId); String wid = String.valueOf(workorderId); session.putValue("workorderId", wid); req.setAttribute("billingsystem", billSystem); req.setAttribute("itemname", itemName); // Include the JSP to Edit Product includeJSP(req, resp, ITEM_JSP_PATH, "editItem"); return; } // Button action from JSP is to Edit a Product else if (sJSPAction.equals("edit")) { String bsysid = req.getParameter("bsId"); session.putValue("bysysidforedit", bsysid); wodId = (new Long((String) req.getParameter("wodId"))).longValue(); // bkId = (new Long( (String) req.getParameter("bkId"))).longValue() ; session.putValue("workorderdetid", String.valueOf(wodId)); bsId = (new Long((String) req.getParameter("bsId"))).longValue(); BlgSys blgSys = new BlgSys(); bsNm = blgSys.getBsName(bsId); // Create db connection for EJB workorderdetEJBean.connect(); // WorkOrder woObj = workorderdetEJBean.getWorkOrderInfo(workorderId); // Get the WorkOrder Number Object WrkOrdrDets wodets_obj = new WrkOrdrDets(); wodets_obj = workorderdetEJBean.getProductInfo(wodId); // Get the List of Billing Keys for the Billing System. String[] blgKeys = workorderdetEJBean.getBillingKeys(customerId, bsId); // Check if the Item has any Credits. If any credits then Billing // Key is not Editable else Editable. if (workorderdetEJBean.hasCredits(wodId)) { req.setAttribute("prodcredit", "Y"); } else { req.setAttribute("prodcredit", "N"); } // Release db connection for EJB workorderdetEJBean.release(); // If Item Object is not null (which generally is the case) then // set the Attributes for the JSP. if (wodets_obj != null) { // Put the Item Object in session editflag = "edit"; session.putValue("wodets", wodets_obj); req.setAttribute("editflag", editflag); // Set the attributes for the Billing System, Billing Key List, req.setAttribute("bkList", blgKeys); req.setAttribute("bsname", bsNm); // Include the JSP to Edit the Item. includeJSP(req, resp, ITEM_JSP_PATH, "editItem"); return; } // If Item Object is null (which generally should not Occur) show // the Default page of Item List for the WorkOrder Number else { // Set the JSP error message req.setAttribute( "errorMsg", "Product Key - " + wodId + " Information not available in the Data Base"); // list items for parent WorkOrder Number listProducts(workorderId, workorderdetEJBean, session, req, resp); return; } } // Button action from JSP is to Delete an Item else if (sJSPAction.equals("delete")) { String formWodId = req.getParameter("wodId"); wodId = (new Long((String) req.getParameter("wodId"))).longValue(); // Create db connection for EJB workorderdetEJBean.connect(); // Delete the Item if (workorderdetEJBean.deleteProduct(wodId)) { req.setAttribute("errorMsg", "Product Key - " + wodId + " Deleted"); } else { req.setAttribute( "errorMsg", "Deletion Failed. Product Key - " + wodId + " is associated with amounts."); } // Release db connection for EJB workorderdetEJBean.release(); // Show the Item List screen listProducts(workorderId, workorderdetEJBean, session, req, resp); return; } // Button action from JSP is to Save a Product. This includes Insertion // of New Product or Updation of an Existing Product. else if (sJSPAction.equals("save")) { boolean save = false; boolean newProd = false; // long qty=0; // Read the Billing System Id String formBsId = (String) req.getParameter("bs_id"); String bsysid = (String) req.getParameter("bsysid"); /* String trans_type = (String) req.getParameter("trans_type"); //String quantity = (String) req.getParameter("qty"); String quantity=""; if (!(req.getParameter("qty").equals(""))) { quantity=(String) req.getParameter("qty"); qty = (new Long(quantity).longValue()); } */ String prod_stat = (String) req.getParameter("prod_stat"); double nrcg_dscnt = (new Double((String) req.getParameter("NonRecurringDiscount"))).doubleValue(); double rcg_dscnt = (new Double((String) req.getParameter("RecurringDiscount"))).doubleValue(); String start_month = (String) req.getParameter("strt_month"); String start_day = (String) req.getParameter("strt_day"); String start_year = (String) req.getParameter("strt_year"); String end_month = (String) req.getParameter("end_month"); String end_day = (String) req.getParameter("end_day"); String end_year = (String) req.getParameter("end_year"); String start_date = start_month + "-" + start_day + "-" + start_year; String end_date = end_month + "-" + end_day + "-" + end_year; long wrkordrid = (new Long((String) session.getValue("WorkOrderId"))).longValue(); String for_editing = req.getParameter("for_editing"); String for_new = req.getParameter("for_new"); String formBkId = (String) req.getParameter("bk_id"); String formBKId = formBkId.substring(0, formBkId.indexOf("|")); String formBTN = formBkId.substring(formBkId.indexOf("|") + 1); billkeyId = (new Long(formBKId)).longValue(); try { bsId = (new Long((String) req.getParameter("bs_id"))).longValue(); } catch (Exception e) { USFEnv.getLog().writeDebug("Exception is " + e, this, null); } RHCCBlgKeys blgkeys = new RHCCBlgKeys(); if (for_editing.equals("editing")) { blgkeys.setRbkId(billkeyId); blgkeys.setRbkKeys(formBTN); blgkeys.setBsId(new Long(bsysid).longValue()); } if (for_new.equals("new")) { blgkeys.setRbkId(billkeyId); blgkeys.setRbkKeys(formBTN); blgkeys.setBsId(bsId); } int index = 0; WrkOrdrDets wod_obj = new WrkOrdrDets(); // wod_obj.setTxTyp(trans_type); // wod_obj.setQty(qty); wod_obj.setNonRcrgDscnt(nrcg_dscnt); wod_obj.setRcrgDscnt(rcg_dscnt); wod_obj.setRBKID(billkeyId); wod_obj.setWodStat(prod_stat); wod_obj.setWOID(wrkordrid); if (!(start_date.equals(""))) { strtDate = new java.sql.Date((new SimpleDateFormat("MM-dd-yyyy")).parse(start_date).getTime()); wod_obj.setStrtDat(strtDate); } // Else if the Start Date is null update the Item Object Date to // null else { wod_obj.setStrtDat(null); } // If Item Service End Date is not null read the date and update // the Item Object with the date if (!(end_date.equals(""))) { endDate = new java.sql.Date((new SimpleDateFormat("MM-dd-yyyy")).parse(end_date).getTime()); wod_obj.setEndDat(endDate); } // Else if the End Date is null update the Item Object Date to null else { wod_obj.setEndDat(null); } // Check if the Start Date is after the End Date or equals End Date if ((strtDate != null) && (endDate != null) && (strtDate.after(endDate))) { prodError = "Product Service Start Date is after Product Service End Date. \n"; index = 1; } else if ((strtDate != null) && (endDate != null) && (strtDate.equals(endDate))) { prodError = "Product Service Start Date equals Product Service End Date. \n"; } workorderdetEJBean.connect(); if (for_editing.equals("editing")) { long workorderdetID = (new Long((String) session.getValue("workorderdetid"))).longValue(); wod_obj.setWODID(workorderdetID); if (index == 0) { save = workorderdetEJBean.saveProduct(wod_obj); } if (save) { prodError = prodError + "<BR> Product Key - " + wod_obj.getWODID() + " Information updated"; req.setAttribute("error", prodError); } else { prodError = prodError + "<BR> Failed to update Product Information"; req.setAttribute("error", prodError); } } if (for_new.equals("new")) { if (index == 0) { int prodId = Integer.parseInt(req.getParameter("prod_Id")); wod_obj.setProd_id(prodId); save = workorderdetEJBean.saveProduct(wod_obj); } if (save) { prodError = prodError + "<BR> Product Key - " + wod_obj.getWODID() + " Information Saved"; req.setAttribute("error", prodError); } else { prodError = prodError + "<BR> Failed to Save Product Information"; req.setAttribute("error", prodError); } } workorderdetEJBean.release(); listProducts(wrkordrid, workorderdetEJBean, session, req, resp); } } // End of try block catch (Exception e) { if (workorderdetEJBean != null) { // calling bean release method try { workorderdetEJBean.release(); } catch (Exception ex) { USFEnv.getLog().writeCrit(" Exception in calling release() method ", this, e); } } String errorMsg = "Processing Exception in Items Servlet: "; USFEnv.getLog().writeCrit(errorMsg, this, e); errorJSP(req, resp, errorMsg); } // End of catch block } // end of doPost()