private void printRemainingDataSourcesList(PrintWriter out, User user, ConnectToDB ctdb)
     throws SQLException {
   DataSource dataSource = null;
   String dataSourceName = null;
   Vector remainingDataSourcesList =
       ctdb.getDataSourceListsDifference(
           this.dataSourceVectorForDataSourceNames(
               ctdb.getValuesVectorForOneColumnUnderOneCondition(
                   new Column("DATASOURCENAME"), new Column("ISCANDIDATE", "no"), "ACDATASOURCE")),
           user.getDataSourceList());
   if (remainingDataSourcesList.size() == 0) {
     out.println("<table class=transparenttable>");
     out.println("<tr><td><FONT COLOR=#000000>No virtaul sensor is available.</td></tr>");
     out.println("</table>");
   } else {
     out.println("<table>");
     out.println("<tr><th> virtual sensor name </th>");
     out.println("<th> access right</th></tr>");
     for (int i = 0; i < remainingDataSourcesList.size(); i++) {
       dataSource = (DataSource) (remainingDataSourcesList.get(i));
       dataSourceName = dataSource.getDataSourceName();
       if (ctdb.valueExistsForThisColumnUnderTwoConditions(
           new Column("ISUSERWAITING", "yes"),
           new Column("USERNAME", user.getUserName()),
           new Column("DATASOURCENAME", dataSource.getDataSourceName()),
           "ACUSER_ACDATASOURCE")) {
         out.println("<tr><td>" + dataSourceName + " </td>");
       } else {
         out.println("<FORM ACTION=/gsn/MyUpdateUserWaitingForDataSourceServlet METHOD=POST>");
         out.println("<tr><td>" + dataSourceName + " </td>");
         out.println("<td><INPUT TYPE=RADIO NAME=" + dataSourceName + " VALUE= 1> read ");
         out.println("<INPUT TYPE=RADIO NAME=" + dataSourceName + " VALUE= 2> write ");
         out.println("<INPUT TYPE=RADIO NAME=" + dataSourceName + " VALUE=3> read/write ");
       }
       if (ctdb.valueExistsForThisColumnUnderTwoConditions(
           new Column("ISUSERWAITING", "yes"),
           new Column("USERNAME", user.getUserName()),
           new Column("DATASOURCENAME", dataSource.getDataSourceName()),
           "ACUSER_ACDATASOURCE")) {
         out.println("<td>" + "<FONT COLOR=#0000FF>in updates waiting list!</td></tr>");
       } else {
         out.println(
             "&nbsp&nbsp&nbsp<INPUT TYPE=SUBMIT TYPE=SUBMIT class= buttonstyle VALUE=\"add\"></td></tr>");
         out.println("</FORM>");
       }
     }
     out.println("</table>");
   }
 }
  /**
   * *************************************************************************************************
   */
  public void doGet(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {
    res.setContentType("text/html");
    PrintWriter out = res.getWriter();
    ConnectToDB ctdb = null;

    // Get the session
    HttpSession session = req.getSession();

    User user = (User) session.getAttribute("user");
    if (user == null) {
      this.redirectToLogin(req, res);
    } else {
      this.checkSessionScheme(req, res);
      if (user.isAdmin() == false) {
        res.sendError(WebConstants.ACCESS_DENIED, "Access denied.");
      } else {
        this.printHeader(out);
        this.printLayoutMastHead(out, user);
        this.printLayoutContent(out);
        try {
          ctdb = new ConnectToDB();
          Vector waitingUsers = ctdb.getWaitingUsers();
          if (waitingUsers.size() == 0) {
            out.println("<p><B> There is no entry in the waiting user list !</B> </p>");
          }
          for (int i = 0; i < waitingUsers.size(); i++) {
            // printForm(out,(User)(waitingUsers.get(i)));

            this.printNewEntry(out, (User) (waitingUsers.get(i)));
          }
        } catch (Exception e) {
          out.println("<p><B> Can not print the form</B> </p>");

          logger.error("ERROR IN DOGET");
          logger.error(e.getMessage(), e);

        } finally {
          if (ctdb != null) {
            ctdb.closeStatement();
            ctdb.closeConnection();
          }
        }
        // out.println("</BODY>");
        this.printLayoutFooter(out);
      }
    }
  }
  private void printRemainingGroupsList(PrintWriter out, User user, ConnectToDB ctdb)
      throws SQLException {
    Vector remainingGroupList =
        ctdb.getGroupListsDifference(ctdb.getGroupList(), user.getGroupList());
    Group group = null;
    String groupName = null;
    String userName = user.getUserName();
    if (remainingGroupList.size() == 0) {
      out.println("<table class =transparenttable>");
      out.println("<tr><td><FONT COLOR=#000000>No group is available.</td></tr>");
      out.println("</table>");
    } else {
      out.println("<table>");
      out.println("<tr>");
      out.println("<th>group name</th>");
      out.println("<th>group structure</th>");
      out.println("<th>updates</th>");
      out.println("</tr>");

      for (int i = 0; i < remainingGroupList.size(); i++) {
        group = (Group) (remainingGroupList.get(i));
        groupName = group.getGroupName();
        out.println("<tr>");
        out.println("<td>" + groupName + "</td>");
        this.printGroupStructureLink(out, groupName);
        if (ctdb.valueExistsForThisColumnUnderTwoConditions(
                new Column("ISUSERWAITING", "yes"),
                new Column("GROUPNAME", groupName),
                new Column("USERNAME", userName),
                "ACUSER_ACGROUP")
            == false) {
          out.println("<FORM ACTION=/gsn/MyUpdateUserWaitingForGroupServlet METHOD=POST>");
          out.println("<INPUT  TYPE=HIDDEN NAME=groupname VALUE=" + groupName + ">");
          out.println("<INPUT  TYPE=HIDDEN NAME=addgroup VALUE=Yes>");
          out.println(
              "<td style=text-align:center><INPUT TYPE=SUBMIT class= buttonstyle VALUE=\"add\"></td>");
          out.println("</FORM>");
        } else {
          out.println("<td>" + "<FONT COLOR=#0000FF>in updates waiting list!</td>");
        }
        out.println("</tr>");
      }
      out.println("</table>");
    }
  }
  /// gsn/MyLogoutHandlerServlet
  private void printForm(PrintWriter out, User user) {

    ConnectToDB ctdb = null;
    try {
      ctdb = new ConnectToDB();

      this.printLayoutMastHead(out, user);

      this.printLayoutContent(out, user, ctdb);
      this.printLayoutSideBar(out, user, ctdb);
      this.printLayoutFooter(out);
    } catch (Exception e) {

      logger.error("ERROR IN printForm");
      logger.error(e.getMessage(), e);

    } finally {
      if (ctdb != null) {
        ctdb.closeStatement();
        ctdb.closeConnection();
      }
    }
  }
  private void printUserDataSourceList(PrintWriter out, User user, ConnectToDB ctdb)
      throws SQLException {
    DataSource dataSource = null;
    String dataSourceName = null;
    String dataSourceType = null;

    if (user.getDataSourceList().size() == 0) {
      out.println("<table class =transparenttable>");
      out.println("<tr><td><FONT COLOR=#000000>No virtaul sensor is available.</td></tr>");
      out.println("</table>");
    } else {
      out.println("<table>");
      out.println("<tr><th> virtual sensor name </th>");
      out.println("<th> access right</th></tr>");
      for (int j = 0; j < user.getDataSourceList().size(); j++) {
        dataSource = (DataSource) user.getDataSourceList().get(j);
        dataSourceName = dataSource.getDataSourceName();
        dataSourceType = dataSource.getDataSourceType();
        if (dataSourceType.equals("4")) {
          out.println("<tr><td>" + dataSourceName + " </td>");
          out.println("<td>own</td></tr>");
        } else {
          if (ctdb.valueExistsForThisColumnUnderTwoConditions(
              new Column("ISUSERWAITING", "yes"),
              new Column("USERNAME", user.getUserName()),
              new Column("DATASOURCENAME", dataSourceName),
              "ACUSER_ACDATASOURCE")) {
            out.println("<tr><td>" + dataSourceName + " </td>");
          } else {
            out.println("<FORM ACTION=/gsn/MyUpdateUserWaitingForDataSourceServlet METHOD=POST>");
            out.println("<tr><td>" + dataSourceName + " </td>");
            if (dataSourceType.charAt(0) == '1') {
              out.println(
                  "<td><INPUT CHECKED TYPE=RADIO NAME=" + dataSourceName + " VALUE= 1>read");
              out.println("<INPUT  TYPE=RADIO NAME=" + dataSourceName + " VALUE= 2>write ");
              out.println("<INPUT  TYPE=RADIO NAME=" + dataSourceName + " VALUE=3>read/write");
              out.println("<INPUT  TYPE=RADIO NAME=" + dataSourceName + " VALUE=0>delete ");
            }
            if (dataSourceType.charAt(0) == '2') {
              out.println("<td><INPUT TYPE=RADIO NAME=" + dataSourceName + " VALUE= 1> read ");
              out.println("<INPUT CHECKED TYPE=RADIO NAME=" + dataSourceName + " VALUE= 2> write ");
              out.println("<INPUT  TYPE=RADIO NAME=" + dataSourceName + " VALUE=3> read/write ");
              out.println("<INPUT  TYPE=RADIO NAME=" + dataSourceName + " VALUE=0> delete ");
            }
            if (dataSourceType.charAt(0) == '3') {
              out.println("<td><INPUT TYPE=RADIO NAME=" + dataSourceName + " VALUE= 1> read ");
              out.println("<INPUT  TYPE=RADIO NAME=" + dataSourceName + " VALUE= 2> write ");
              out.println(
                  "<INPUT CHECKED TYPE=RADIO NAME=" + dataSourceName + " VALUE=3> read/write ");
              out.println("<INPUT  TYPE=RADIO NAME=" + dataSourceName + " VALUE=0> delete ");
            }
          }
          if (ctdb.valueExistsForThisColumnUnderTwoConditions(
              new Column("ISUSERWAITING", "yes"),
              new Column("USERNAME", user.getUserName()),
              new Column("DATASOURCENAME", dataSourceName),
              "ACUSER_ACDATASOURCE")) {
            out.println("<td>" + "<FONT COLOR=#0000FF>in updates waiting list!</td></tr>");

          } else {

            out.println(
                "&nbsp&nbsp&nbsp<INPUT TYPE=SUBMIT class= buttonstyle VALUE=\"update\"></td></tr>");
            out.println("</FORM>");
          }
        }
      }
      out.println("</table>");
    }
  }