/** @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    PrintWriter out = response.getWriter();
    response.setContentType("text/html");
    String fname_login;
    try {
      String user_name = request.getParameter("user");
      String password = request.getParameter("pwd");
      proxy.setEndpoint("http://localhost:8080/svlm/services/VideoLibraryManagement");

      fname_login = proxy.signIn(user_name, password);
      HttpSession session = request.getSession();

      /*if(fname_login.substring(0,5).equalsIgnoreCase("false"))
      {
      	out.println(fname_login.substring(6));
      	out.println("\nInvalid username and password\n");
      	out.println("\n <a href=\"SignIn.jsp\"><br>Try Login Again</a>");
      	out.println("\n <a href=\"SignUp.jsp\"><br>Click here to Register</a>");

      }*/

      if (!fname_login.substring(0, 4).equalsIgnoreCase("false")) {

        String delimiter = "[$]";
        String custname[] = fname_login.split(delimiter);

        // user.add(custname[1]);
        // session.setAttribute("newuser", user);
        // out.println(user);
        // out.println("Login time"+custname[1]);

        out.println("User name" + custname[3]);
        out.println("Successfuly login" + custname[2]);
        out.println("Country is" + custname[9]);

        perobj1.setLogintime(custname[1]);
        perobj1.setUsername(custname[2]);
        perobj1.setFirstname(custname[3]);
        perobj1.setLastname(custname[4]);
        perobj1.setType(custname[5]);
        perobj1.setAddress(custname[6]);
        perobj1.setCity(custname[7]);
        perobj1.setState(custname[8]);
        perobj1.setZipcode(custname[9]);
        perobj1.setMemberid(custname[10]);
        perobj1.setCountry(custname[11]);

        session.setAttribute("per", perobj1);

        response.sendRedirect("home.jsp");
        // response.sendRedirect("updateperson.jsp");
        out.println("\n <a href=\"personprofile.jsp\"><br>Personr Profile</a>");
        out.println("\n <a href=\"searchperson.jsp\"><br>Search Personr</a>");
        out.println("\n <a href=\"updateperson.jsp\"><br>Update Person</a>");

        // session.setAttribute("fname",custname[1]);
        // session.setAttribute("username",custname[2]);
        // session.setAttribute("userlist",user);
      } else {

        out.println(fname_login.substring(6));
        out.println("\nInvalid username and password\n");
        out.println("\n <a href=\"SignIn.jsp\"><br>Try Login Again</a>");
        out.println("\n <a href=\"SignUp.jsp\"><br>Click here to Register</a>");
      }

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
 @Override
 public int compare(Person o1, Person o2) {
   // TODO Auto-generated method stub
   int temp = o1.getName().compareTo(o2.getName());
   return temp == 0 ? o1.getAge() - o2.getAge() : temp;
 }
  /** @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */
  @Override
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    // TODO Auto-generated method stub
    PrintWriter out = response.getWriter();
    response.setContentType("text/html");
    String qdone;
    int i;
    try {

      System.out.println("hi !!!");
      HttpSession session = request.getSession(true);
      Person person = (Person) session.getAttribute("per1");
      String memid = person.getMemberid();
      String[] mn = new String[10000];
      int[] t = new int[10000];
      int[] mid = new int[10000];
      int[] count = new int[10000];
      // System.out.println(m);
      int coun = (Integer) session.getAttribute("total");
      System.out.println("---------------------->" + coun);
      for (i = 0; i < coun; i++) {
        System.out.println(
            "------------------------------------------------------->>>>>>"
                + request.getParameter("check" + i));
        if (request.getParameter("check" + i) != null
            && request.getParameter("check" + i).equals("checked")) {
          System.out.println("entered iffffffffffffffffffff");
          mn[i] = request.getParameter("movname" + i);
          System.out.println(mn[i]);
          mid[i] = Integer.parseInt(request.getParameter("movid" + i));
          System.out.println(mid[i]);
          t[i] = Integer.parseInt(request.getParameter("tid" + i));
          System.out.println(t[i]);
          count[i] = Integer.parseInt(request.getParameter("number" + i));
          System.out.println("-------------------->" + count[i]);
          System.out.println(mn[i]);
          System.out.println(mid[i]);
          System.out.println(t[i]);
          System.out.println("-------------------->" + count[i]);
        } else {
          System.out.println("i am in else");
          // break;
        }
      }

      DateFormat timef = new SimpleDateFormat("HH:mm:ss");
      Date date1 = new Date();
      System.out.println("------------------->" + timef.format(date1));
      String time = timef.format(date1);
      DateFormat datef = new SimpleDateFormat("yyyy/MM/dd");
      Date date2 = new Date();
      System.out.println("------------------->" + datef.format(date2));
      String date = datef.format(date2);
      String retDateandTime = date + "$" + time;
      System.out.println("------------------->" + retDateandTime);
      String movname = "", cou = "", tid = "", movids = "";
      for (int j = 0; j < 10; j++) {
        if (mn[j] != null) movname += mn[j] + "$";
        if (count[j] != 0) cou += count[j] + "#";
        if (t[j] != 0) tid += t[j] + "$";
        if (mid[j] != 0) movids += mid[j] + "$";
      }
      System.out.println("movie nameeeeeeeeeeee------------------->" + movname);
      System.out.println("movie nameeeeeeeeeeee------------------->" + movids);
      System.out.println("counttttttttttt------------------->" + cou);
      System.out.println("tidddddddddddd------------------->" + tid);

      proxy.setEndpoint("http://localhost:8080/svlm/services/VideoLibraryManagement");

      qdone = proxy.returnMovie(memid, movids, movname, cou, retDateandTime, tid);

      if (qdone.equals("true")) {
        // session.setAttribute("userSession",session);
        out.println("Return id successfull");
        String dest = "home.jsp";
        response.sendRedirect(dest);
      } else {
        out.println(qdone.substring(6));
        out.println("\n<a href=\"signUp.jsp\"><br>Go back to sign up again</a>");
      }

    } catch (Exception e) {
      e.getStackTrace();
    }
  }
package Generic.JsonDemo;