Exemplo n.º 1
0
  public void doPost(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {

    // 取得Session对象
    // 如果Session不存在,为本次会话创建此对象
    HttpSession session = req.getSession(true);
    Integer itemCount = (Integer) session.getValue("itemCount");
    // 如果session是新的
    if (itemCount == null) itemCount = new Integer(0);

    PrintWriter out = res.getWriter();
    res.setContentType("text/html");

    // 接收传来的参数
    String[] itemsSelected;
    String itemName;
    itemsSelected = req.getParameterValues("item");

    if (itemsSelected != null) {
      for (int i = 0; i < itemsSelected.length; i++) {
        itemName = itemsSelected[i];
        System.out.println(itemName);
        itemCount = new Integer(itemCount.intValue() + 1);
        // 购买的条目
        session.putValue("item" + itemCount, itemName);
        // 总条目
        session.putValue("itemCount", itemCount);
      }
    }

    out.println("<html>");
    out.println("<title>");
    out.println("item list");
    out.println("</title>");
    out.println("<body><h4>Session List:</h4><hr><br><br>");
    for (int i = 1; i <= itemCount.intValue(); i++) {
      out.println((String) session.getValue("item" + i) + "<hr>");
    }
    out.println("</body>");
    out.println("</html>");
    out.close();
  }
Exemplo n.º 2
0
  public void service(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {
    res.setContentType("text/html");
    int cost;
    PrintWriter out = res.getWriter();
    System.out.println("CreditCard");

    HttpSession CCsession = req.getSession(true);
    cost = (Integer) CCsession.getValue("ba");

    Integer billamt = new Integer(cost);
    CCsession.putValue("ba", billamt);

    out.println("<html>");
    out.println("<title>CC..</title>");
    out.println("<body bgcolor=#737CA >");

    out.println("<form action=\"http://localhost:8080/servlet/CreditThanks\">");

    out.println("<font size=36 align=center color=#ffd7ff>");
    out.println("<center>Payment mode: Credit Card</center></font><br><br>");
    out.println("<br><br><br><br>");

    out.println("<font size=4>Enter your user id:");
    out.println("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
    out.println("&nbsp;&nbsp;&nbsp;");
    out.println("<input type=text name=\"userid\">");
    out.println("<br><br>Enter your Credit card no:");
    out.println("&nbsp;&nbsp;&nbsp;&nbsp;");
    out.println("<input type=text name=\"cardno\"><br><br>");

    out.println("Enter your Bank name:");
    out.println("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
    out.println("<input type=text name=\"bankname\"><br><br>");

    out.println("Bill amount:</b>");
    out.println(
        "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");

    out.println("&nbsp;&nbsp;&nbsp;&nbsp;Rs. &nbsp;");
    out.println("<input type=text name=\"billamt\" value=" + cost + ">&nbsp;&nbsp;/-");
    out.println("</font><br><br><br><br>");

    out.println("<input type=submit value=\"submit\">");

    out.println("</form></body></html>");
  } // service
Exemplo n.º 3
0
  public boolean handleSecurity(HttpServletRequest request, HttpServletResponse response)
      throws IOException {

    // we need http scheme!
    if (enableHttps && !request.getScheme().equals("https")) {
      try {
        response.sendError(HttpServletResponse.SC_FORBIDDEN);
      } catch (IOException e) {
        // do nothing
      }
      return false;
    }

    String queryString = request.getRequestURI();

    if (queryString.equals(applicationWebAlias + "/conf")
        || (queryString.equals(applicationWebAlias + "/conf/"))) {
      response.sendRedirect(applicationWebAlias + "/conf/index_embedded.html");
      return true;
    } else if (queryString.equals(applicationWebAlias)
        || (queryString.equals(applicationWebAlias + "/"))) {
      response.sendRedirect(applicationWebAlias + "/index.html");
      return true;
    }

    if (enableSecurity) {
      if (useBasic) {
        String auth = request.getHeader("Authorization");

        if (auth == null) return failAuthorization(request, response);

        StringTokenizer tokens = new StringTokenizer(auth);
        String authscheme = tokens.nextToken();

        if (!authscheme.equals("Basic")) return failAuthorization(request, response);

        String base64credentials = tokens.nextToken();
        String credentials = new String(Base64.decode(base64credentials.getBytes()));
        int colon = credentials.indexOf(':');
        String userid = credentials.substring(0, colon);
        String password = credentials.substring(colon + 1);
        Authorization subject = null;

        try {
          subject = login(request, userid, password);
        } catch (LoginException e) {
          return failAuthorization(request, response);
        }

        request.setAttribute(HttpContext.REMOTE_USER, userid);
        request.setAttribute(HttpContext.AUTHENTICATION_TYPE, authscheme);
        request.setAttribute(HttpContext.AUTHORIZATION, subject);
      } else {
        HttpSession session = request.getSession(true);
        if (queryString.startsWith(applicationWebAlias + "/conf")) {
          // this is a restricted area so performs login

          String a = request.getMethod();
          String submit = request.getParameter("submit");
          if (submit != null) {
            String username = request.getParameter("username");
            String password = request.getParameter("password");
            if (!allowUser(username, password)) {
              return redirectToLoginPage(request, response);
            } else {
              session.putValue("logon.isDone", username);
              try {
                String target = (String) session.getValue("login.target");
                if (target != null) response.sendRedirect(target);
                else {
                  response.sendRedirect(applicationWebAlias + "/conf/index_embedded.html");
                }
              } catch (Exception ignored) {
                return false;
              }
            }
          } else {
            if (queryString.equals(applicationWebAlias + "/conf/login.html")) {
              return true;
            } else {
              //							session.putValue("login.target",
              // HttpUtils.getRequestURL(request).toString());
              session.putValue("login.target", applicationWebAlias + "/conf/index_embedded.html");
              Object done = session.getValue("logon.isDone");
              if (done == null) {
                if (request.getMethod().equals("GET")) {
                  return redirectToLoginPage(request, response);
                } else {
                  response.sendError(HttpServletResponse.SC_FORBIDDEN);
                  return false;
                }
              }
            }
          }
        }
      }
    }

    if (request.getRequestURI().endsWith(".png")) {
      response.setHeader("Cache-Control", "public, max-age=10000");
    }

    /*if (request.getRequestURI().endsWith(".js")) {
    	response.setHeader("Pragma", "no-cache");
    	response.setHeader("Cache-Control", "no-store");
    	response.setHeader("Cache-Control", "public, max-age=0");
    }*/

    // response.addHeader(HttpServletResponse, arg1)

    return true;
  }
Exemplo n.º 4
0
  public void service(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {
    res.setContentType("text/html");
    PrintWriter out = res.getWriter();

    Connection con = null;

    String bnm[] = req.getParameterValues("Comics");

    String qty[] = new String[bnm.length];
    ArrayList al1 = new ArrayList();
    ArrayList al2 = new ArrayList();
    for (int i = 0; i < bnm.length; i++) {
      qty[i] = req.getParameter(bnm[i]);
      al1.add(bnm[i]);
      al2.add(qty[i]);
    }

    HttpSession HSession = req.getSession(true);

    ArrayList alo1 = (ArrayList) HSession.getValue("bNames");
    ArrayList alo2 = (ArrayList) HSession.getValue("bQty");

    al1.addAll(alo1);
    al2.addAll(alo2);

    HSession.putValue("bNames", al1);
    HSession.putValue("bQty", al2);

    out.println("<html>");
    out.println("<title>Categories..</title>");
    out.println("<body bgcolor=gold >");

    out.println("<b><font face=\"Papyrus\" size=36 color= #806F7E><center>");
    out.println("<big>Category</big></center>");

    out.println("<ul type=disc>");
    out.println("<font face=\"Maiandra GD\" color=black size=4>");
    out.println("<li type=square>Choose your category..");
    out.println("</li></font><br>");

    out.println(
        "<A href=\"FictionClick\"><font face=\"Mistral\" size=8 color=#208234><b>Fiction</b></A><br>");

    out.println(
        "<A href=\"NonFictionClick\"><font face=\"Mistral\" size=8 color=#208234><b>Non-Fiction</b></A><br>");

    out.println(
        "<A href=\"AutobiographyClick\"><font face=\"Mistral\" size=8 color=#208234><b>Autobiography</b></A><br>");

    out.println(
        "<A href=\"HistoryClick\"><font face=\"Mistral\" size=8 color=#208234><b>History</b></A><br>");

    out.println(
        "<A href=\"ComicsClick\"><font face=\"Mistral\" size=8 color=#208234><b>Comics</b></A></font><br><br>");

    out.println("<center><form action=\"http://localhost:8080/servlet/FinalList\">");
    out.println("<input type=submit value=\" Finalize List >>\"></form>");

    out.println("<font face=\"Maiandra GD\" color=black size=4>");
    out.println("Moves to final List..</center>");

    out.println("</font></body>");
    out.println("</html>");
  } // service
Exemplo n.º 5
0
  /**
   * cette methode permet de Recuperation de la liste de tous les spectacles de la saison. ent
   * construisant une une page web decrivant ces spectacles.
   *
   * @param req an HttpServletRequest object that contains the request the client has made of the
   *     servlet
   * @param res an HttpServletResponse object that contains the response the servlet sends to the
   *     client
   * @throws ServletException if the request for the GET could not be handled
   * @throws IOException if an input or output error is detected when the servlet handles the GET
   *     request
   */
  public void doGet(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {
    ServletOutputStream out = res.getOutputStream();
    HttpSession session = req.getSession(true);
    res.setContentType("text/html");
    out.println("<HEAD><TITLE> Programme de la saison </TITLE></HEAD>");
    out.println("<BODY bgproperties=\"fixed\" background=\"/images/rideau.JPG\">");
    out.println("<font color=\"#FFFFFF\"><h1> Programme de la saison </h1>");
    out.println("<FORM METHOD=POST>");
    if (session.isNew()) {

      session.putValue("expand", null);
      session.putValue("rslt", null);
    }

    int[] expand = (int[]) session.getValue("expand");
    Vector<Spectacle> rslt = (Vector<Spectacle>) session.getValue("rslt");
    try {
      Utilisateur user = Utilitaires.Identification(this);

      if (rslt == null) {
        out.println("<p><i><font color=\"#FFFFFF\">actualy NEW</i></p>");

        rslt = Utilitaires.getProgramme(user);
        session.putValue("rslt", rslt);
        if (rslt.isEmpty()) {
          out.println(" Liste vide <br>");
        } else {
          expand = new int[rslt.size()];
          Arrays.fill(expand, 0);
          session.putValue("expand", expand);
          for (int i = 0; i < rslt.size(); i++) {
            out.println(
                "<INPUT TYPE=SUBMIT NAME=LR"
                    + rslt.elementAt(i).getNum()
                    + " VALUE="
                    + "\"+\" >  "
                    + rslt.elementAt(i).getNom()
                    + "<br>");
          }
        }
      } else {

        for (int i = 0; i < rslt.size(); i++) {
          if (req.getParameter("LR" + rslt.elementAt(i).getNum()) != null) {
            expand[i] = 1;
          } else if (req.getParameter("less" + rslt.elementAt(i).getNum()) != null) {
            expand[i] = 0;
          }
          if (expand[i] == 0) {
            out.println(
                "<INPUT TYPE=SUBMIT NAME=LR"
                    + rslt.elementAt(i).getNum()
                    + " VALUE="
                    + "\"+\" >"
                    + rslt.elementAt(i).getNom()
                    + "<br>");

          } else {
            out.println(
                "<INPUT TYPE=SUBMIT NAME=less"
                    + rslt.elementAt(i).getNum()
                    + " VALUE="
                    + "\"-\" >"
                    + rslt.elementAt(i).getNom()
                    + "<br>");
            out.println(Utilitaires.listerRepresentations(user, rslt.elementAt(i).getNum()));
          }
        }
      }

    } catch (Exception e) {
      out.println(e.getMessage());
    }
    out.println("</FORM></BODY>");
    out.println("<hr><p><font color=\"#FFFFFF\"><a href=\"/index.html\">Accueil</a></p>");

    out.close();
  }
Exemplo n.º 6
0
  /** @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */
  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    final DataTableRequestParam param = DataTablesParamUtility.getParam(request);

    String sEcho = param.sEcho;
    int iTotalRecords = 0; // total number of records (unfiltered)
    int iTotalDisplayRecords = 0; // value will be set when code filters companies by keyword
    // DBConnection dbconn = new DBConnection();
    ErateProducts erateProducts = new ErateProducts();
    HttpSession session = request.getSession();
    Connection conn = null;
    DBConn dbconn = new DBConn();
    if (conn == null) {
      conn = dbconn.open();
    }
    JSONArray data = new JSONArray(); // data that will be shown in the table
    try {
      iTotalRecords = erateProducts.getProductCount(conn);
    } catch (Exception e2) {
      // TODO Auto-generated catch block
      e2.printStackTrace();
    }
    // iTotalRecords = DataRepository.GetCompanies().size();
    // List<ProductDataDao> companies = new LinkedList<ProductDataDao>();
    List<ProductDataDao> companies = new LinkedList(Collections.nCopies(iTotalRecords, null));
    ProductDataDao dao = new ProductDataDao();
    System.out.println("company size" + DataRepository.GetCompanies().size());
    // for (int i=0;i<iTotalRecords;i++){
    // List arr ;

    boolean flag = false;
    String searchValue = param.sSearchKeyword.toLowerCase();
    //	System.out.println("testing search.."+param.sSearchKeyword.toLowerCase());
    USFEnv.getLog().writeDebug("testing search.." + param.sSearchKeyword.toLowerCase(), this, null);
    if (!searchValue.equals("")) {
      flag = true;

    } else {

    }
    String var = "NotInSearch";
    session.setAttribute("companySize", var);

    if (param.bSearchable[1] && flag) {
      try {
        dao = erateProducts.searchCRISProduct(param.sSearchKeyword.toLowerCase(), conn);

        if (dao.getProductCode() == null) {
          companies.clear();
        } else {
          session.removeAttribute("companySize");
          companies.clear();
          companies.add(dao);
          if (companies.size() > 0) {
            var = "inFilteredRecord";
            session.setAttribute("companySize", var);
          } else {
            var = "outSideFilteredRecord";
            session.setAttribute("companySize", var);
          }
          // session.setAttribute("companySize",companies.size());
        }
        //	iTotalDisplayRecords1 =companies.size();
      } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
      if (dao.getProductCode() != null) {
        // boolean flag= true;
        // companies.add(dao);
      }
    }

    //	boolean flag = false;

    /*	if(	param.bSearchable[1])  {
    	try {
    		dao = dbconn.searchProduct(param.sSearchKeyword.toLowerCase());
    	} catch (Exception e) {
    		// TODO Auto-generated catch block
    		e.printStackTrace();
    	}
    	if(dao.getProductCode()!=null ){
    	boolean flag= true;
    	companies.add(dao);
    	}
    }*/
    //	param.sSearchKeyword.toLowerCase()
    // if(	param.bSearchable[1] &&
    //	c.getName().toLowerCase().contains(param.sSearchKeyword.toLowerCase())
    //	|| param.bSearchable[2] &&
    // c.getAddress().toLowerCase().contains(param.sSearchKeyword.toLowerCase())
    //	|| param.bSearchable[3] &&
    // c.getTown().toLowerCase().contains(param.sSearchKeyword.toLowerCase()))

    // }

    /*for(ProductDataDao c : iTotalRecords){
    	//Cannot search by column 0 (id)
    	if(	param.bSearchable[1] &&
    		c.getName().toLowerCase().contains(param.sSearchKeyword.toLowerCase())
    		||
    		param.bSearchable[2] &&
    		c.getAddress().toLowerCase().contains(param.sSearchKeyword.toLowerCase())
    		||
    		param.bSearchable[3] &&
    		c.getTown().toLowerCase().contains(param.sSearchKeyword.toLowerCase()))
    	{
    	//	companies.add(c); // Add a company that matches search criterion
    	}
    }*/

    try {
      iTotalDisplayRecords = erateProducts.getProductCount(conn);
      USFEnv.getLog().writeDebug("iTotalDisplayRecords" + iTotalDisplayRecords, this, null);
      //	System.out.println("iTotalDisplayRecords"+iTotalDisplayRecords);
    } catch (Exception e2) {
      // TODO Auto-generated catch block
      e2.printStackTrace();
    }
    // iTotalDisplayRecords = companies.size();//Number of companies that matches search criterion
    // should be returned
    USFEnv.getLog()
        .writeDebug(
            " before param.iDisplayStart"
                + param.iDisplayStart
                + "companies.size()"
                + companies.size(),
            this,
            null);

    //	System.out.println(" before
    // param.iDisplayStart"+param.iDisplayStart+"companies.size()"+companies.size());
    if (companies.size() < param.iDisplayStart + param.iDisplayLength) {

      companies = companies.subList(param.iDisplayStart, companies.size());
    } else {
      try {
        // System.out.println(" after
        // param.iDisplayStart"+param.iDisplayStart+"param.iDisplayLength"+param.iDisplayLength);
        companies =
            erateProducts.getProductInfo(
                param.iDisplayStart, param.iDisplayStart + param.iDisplayLength, conn);
        System.out.println("after");
        try {
          if (conn != null) {
            conn.close();
          }
        } catch (Exception e) {
          // TODO: handle exception
        }

      } catch (Exception e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
      }
    }
    // System.out.println(" after
    // param.iDisplayStart"+param.iDisplayStart+"param.iDisplayLength"+param.iDisplayLength);

    USFEnv.getLog()
        .writeDebug(
            " after param.iDisplayStart"
                + param.iDisplayStart
                + "param.iDisplayLength"
                + param.iDisplayLength,
            this,
            null);

    session.putValue("param.iDisplayStart", param.iDisplayStart);
    session.putValue("param.length", param.iDisplayStart + param.iDisplayLength);

    try {
      JSONObject jsonResponse = new JSONObject();

      jsonResponse.put("sEcho", sEcho);
      jsonResponse.put("iTotalRecords", iTotalRecords);
      jsonResponse.put("iTotalDisplayRecords", iTotalDisplayRecords);

      for (ProductDataDao c : companies) {
        JSONArray row = new JSONArray();
        row.put(c.getSeq_id())
            .put(c.getProductCode())
            .put(c.getDescription())
            .put(c.getModifiedBy())
            .put((new SimpleDateFormat("MM/dd/yyyy")).format((java.util.Date) c.getModifiedDate()));
        data.put(row);
      }
      jsonResponse.put("aaData", data);

      response.setContentType("application/json");
      response.getWriter().print(jsonResponse.toString());
    } catch (JSONException e) {
      e.printStackTrace();
      response.setContentType("text/html");
      response.getWriter().print(e.getMessage());
    } finally {
      try {
        conn.close();
      } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
  }
Exemplo n.º 7
0
 @SuppressWarnings("deprecation")
 @Override
 public void putValue(String name, Object value) {
   httpSession.putValue(name, value);
   putToRedis(name, value);
 }
Exemplo n.º 8
0
  /**
   * 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()
Exemplo n.º 9
0
 @Override
 public void putValue(String name, Object value) {
   sess.putValue(name, value);
 }
Exemplo n.º 10
0
  public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    try {
      String jsppath = "rhccinvoice";
      String year = "";
      String spin = "";
      String frn = "";
      String invid = "";
      String invno = "";
      String spinnm = "";
      String frame = "";
      String user = "";
      Vector vector = new Vector();
      HttpSession session = request.getSession(false);

      if (session == null) {
        jsppath = "login";
        USFEnv.getLog().writeCrit("RhccInvviewServlet: Inside Session is null", this, null);
        USFEnv.getLog()
            .writeWarn("RhccInvviewServlet: Inside frame session calling JSP Login", this, null);
        includeJSP(request, response, jsppath, "Login");
      } else {

        jsppath = "rhccinvoice";
        frame = request.getParameter("frame");
        user = (String) session.getValue("cuid");
        USFEnv.getLog()
            .writeDebug("RhccInvviewServlet: Inside doPost Login CUID is: " + user, this, null);
        USFEnv.getLog()
            .writeWarn("RhccInvviewServlet: Inside InvreconServlet Frame is:" + frame, this, null);

        if (frame.equals("iview_frn")) {
          boolean discountview_flag = false;
          if ((request.getParameter("idiscountview") != null)
              && (request.getParameter("idiscountview").equals("TRUE"))) {
            year = request.getParameter("iyear");
            session.putValue("Iyear", year);
            discountview_flag = true;
          }

          if ((discountview_flag) || (session.getValue("Iyear") != null)) {

            if ((request.getParameter("ifrn")) != null) {
              frn = request.getParameter("ifrn");
              USFEnv.getLog().writeDebug("RhccInvviewServlet: FRN Value :" + frn, this, null);
              if (!(discountview_flag)) {
                year = (String) session.getValue("Iyear");
              }
              Vector frninvnos = new Vector();
              Vector invnolist = new Vector();
              Vector invpending = new Vector();
              boolean frn_flag = false;
              String frnerrmsg = "";

              try {
                invviewEJBean.connect();
                USFEnv.getLog()
                    .writeWarn(
                        "RhccInvviewServlet: Inside frame rhcciview_frn connected to RhccInvviewBean",
                        this,
                        null);

                if (discountview_flag) {
                  frn_flag = true;
                } else {
                  frn_flag = invviewEJBean.validateFRN(frn, year);
                  USFEnv.getLog()
                      .writeWarn(
                          "RhccInvviewServlet:Inside frame rhcciview_frn data from validateFRN"
                              + frn_flag,
                          this,
                          null);
                }

                if (frn_flag) {
                  frninvnos = invviewEJBean.getFrninvnos(year, frn);
                  USFEnv.getLog().writeWarn("ouside the block", this, null);

                  invviewEJBean.release();
                  USFEnv.getLog()
                      .writeWarn(
                          "RhccInvviewServlet: Inside frame Rhcciview_frn released RhccInvviewBean",
                          this,
                          null);
                } else {
                  USFEnv.getLog()
                      .writeWarn(
                          "RhccInvviewServlet: Inside frame iview_frn Inside the else block",
                          this,
                          null);

                  frnerrmsg = invviewEJBean.setErrmsg();

                  invviewEJBean.release();
                  USFEnv.getLog()
                      .writeWarn(
                          "RhccInvviewServlet: Inside frame iview_frn released RhccInvviewBean"
                              + frnerrmsg,
                          this,
                          null);
                  invgenEJBean.connect();
                  USFEnv.getLog()
                      .writeWarn(
                          "RhccInvviewServlet: Inside frame iview_frn connected to RhccInvgenBean"
                              + invnolist,
                          this,
                          null);
                  invnolist = invgenEJBean.getRhccInvnos(year);
                  USFEnv.getLog().writeWarn("outside of this " + invnolist, this, null);

                  invgenEJBean.release();
                  USFEnv.getLog()
                      .writeWarn(
                          "RhccInvviewServlet: Inside frame iview_frn released RhccInvgenBean",
                          this,
                          null);
                }
                USFEnv.getLog()
                    .writeWarn(
                        "RhccInvviewServlet: Inside frame iview_frn Inside the else block--2--",
                        this,
                        null);

                if (discountview_flag) {
                  USFEnv.getLog()
                      .writeWarn(
                          "RhccInvviewServlet: Inside -3---" + discountview_flag, this, null);
                  USFEnv.getLog().writeWarn("RhccInvviewServlet: Inside -3---" + frn, this, null);
                  USFEnv.getLog().writeWarn("RhccInvviewServlet: Inside -3---" + year, this, null);
                  session.putValue("Ifrn", frn);
                  invgenEJBean.connect();
                  USFEnv.getLog()
                      .writeWarn("RhccInvviewServlet: Inside frame----88 " + frn, this, null);
                  invpending = invgenEJBean.getRhccInvpending(null, year, frn);
                  USFEnv.getLog()
                      .writeWarn(
                          "RhccInvviewServlet: Inside frame iview_frn connected to InvgenBean",
                          this,
                          null);
                  invgenEJBean.release();
                  USFEnv.getLog()
                      .writeWarn(
                          "RhccInvviewServlet: Inside frame iview_frn released InvgenBean",
                          this,
                          null);
                }

              } catch (RemoteException e) {

                USFEnv.getLog().writeCrit("I m here", this, null);

                USFEnv.getLog()
                    .writeCrit(
                        "RhccInvviewServlet: Inside Remote Exception of getFrninvnos ", this, null);
              }

              if (frn_flag) {
                USFEnv.getLog()
                    .writeWarn(
                        "RhccInvviewServlet: Inside frame iview_frn calling JSP RhccIInvviewfrn"
                            + frn_flag,
                        this,
                        null);

                request.setAttribute("frn", frn);
                request.setAttribute("frninv", frninvnos);
                USFEnv.getLog()
                    .writeWarn(
                        "RhccInvviewServlet: Inside frame iview_frn calling JSP RhccIInvviewfrn",
                        this,
                        null);

                if (discountview_flag) {
                  if ((request.getParameter("invrejn") != null)
                      && (request.getParameter("invrejn").equals("true")))
                    request.setAttribute("invrejn", "true");

                  request.setAttribute("frnpend", invpending);
                  includeJSP(request, response, jsppath, "RhccIDiscountview");
                } else {
                  USFEnv.getLog()
                      .writeWarn(
                          "RhccInvviewServlet:  Inside frame iview_frn calling JSP RhccIInvviewfrn inside else",
                          this,
                          null);

                  includeJSP(request, response, jsppath, "RhccIInvviewfrn");
                }
              } else {
                request.setAttribute("invnolist", invnolist);
                request.setAttribute("invviewmsg", frnerrmsg);
                USFEnv.getLog()
                    .writeWarn(
                        "RhccInvviewServlet: Inside frame iview_frn calling JSP IMenu", this, null);
                includeJSP(request, response, jsppath, "RhccIMenu");
              }
            }
          }
        }

        if (frame.equals("iview_file")) {
          boolean discountview_flag = false;
          frn = request.getParameter("ifrn");
          invid = request.getParameter("iview_no");
          USFEnv.getLog()
              .writeWarn(
                  "RhccInvviewServlet: Inside frame iview_file released InvviewBean" + frn,
                  this,
                  null);
          USFEnv.getLog()
              .writeWarn(
                  "RhccInvviewServlet: Inside frame iview_file released InvviewBean" + invid,
                  this,
                  null);

          Vector invfil = new Vector();

          if ((request.getParameter("idiscountview") != null)
              && (request.getParameter("idiscountview").equals("TRUE"))) {
            year = request.getParameter("iyear");
            session.putValue("Iyear", year);
            discountview_flag = true;
          }

          if (invid != null) {
            if (session.getValue("Iyear") != null) {
              year = (String) session.getValue("Iyear");

              try {
                invviewEJBean.connect();
                USFEnv.getLog()
                    .writeWarn(
                        "RhccInvviewServlet: Inside frame iview_file connected to RhccInvviewBean",
                        this,
                        null);
                invno = invviewEJBean.getInvno(invid);
                spinnm = invviewEJBean.getSPINname(invid);
                invfil = invviewEJBean.getFiledetails(frn, invid, year);
                invviewEJBean.release();
                USFEnv.getLog()
                    .writeWarn(
                        "RhccInvviewServlet: Inside frame iview_file released RhccInvviewBean",
                        this,
                        null);
              } catch (RemoteException e) {
                USFEnv.getLog()
                    .writeCrit("RhccInvviewServlet: Inside Remote Exception for Inv ", this, null);
              }
            }
          }

          if (discountview_flag) {
            request.setAttribute("vdsflag", "TRUE");
          }
          if ((request.getParameter("invrejn") != null)
              && (request.getParameter("invrejn").equals("true")))
            request.setAttribute("invrejn", "true");

          request.setAttribute("frn", frn);
          request.setAttribute("invno", invno);
          request.setAttribute("spinnm", spinnm);
          request.setAttribute("invfil", invfil);
          USFEnv.getLog()
              .writeWarn(
                  "RhccInvviewServlet: Inside frame iview_file calling JSP RhccIInvviewfil",
                  this,
                  null);
          includeJSP(request, response, jsppath, "RhccIInvviewfil");
        }
      }
    } catch (Exception e) {
      if (invviewEJBean != null) {
        // calling bean release method
        try {
          invviewEJBean.release();
        } catch (Exception ex) {
          USFEnv.getLog().writeCrit(" Exception in calling release() method ", this, e);
        }
      }
      USFEnv.getLog().writeCrit("RhccInvviewServlet: Inside Exception" + e, this, null);
      USFEnv.getLog()
          .writeWarn("RhccInvviewServlet: Inside Exception calling JSP Login", this, null);
      includeJSP(request, response, "login", "Login");
    }
  }