Esempio n. 1
0
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    PrintWriter writer = response.getWriter();
    String noteName = request.getParameter("noteName");
    String note = request.getParameter("note");

    try {
      Class.forName("com.mysql.jdbc.Driver");
      Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/evernoteDB");

      Statement st = con.createStatement();

      st.executeUpdate(
          "INSERT INTO note (noteName, note) VALUES ('" + noteName + "','" + note + "')");

      response.sendRedirect("/userNotes.jsp");
    } catch (ClassNotFoundException e) {
      writer.println("Couldn't load database driver: " + e.getMessage());
    } catch (SQLException e) {
      writer.println("SQLException caught: " + e.getMessage());
    } catch (Exception e) {
      writer.println(e);
    }
  }
Esempio n. 2
0
  // Generate files for given node
  // Given Hashtable mapping node_name to Vector of cluster names
  // <Node>.ini File format:
  // [ Clusters ]
  // cluster = <clustername>
  // ...
  private void dumpNodeInfo(Hashtable all_nodes, String path) throws IOException {
    PrintWriter node_file;
    // Iterate over hashtable of nodes and write <Node>.ini file for each
    for (Enumeration e = all_nodes.keys(); e.hasMoreElements(); ) {
      String node_name = (String) (e.nextElement());

      try {
        if (path != null) {
          node_file = createPrintWriter(path + File.separator + node_name + ".ini");
        } else {
          node_file = createPrintWriter(node_name + ".ini");
        }
        node_file.println("[ Clusters ]");
        Vector clusters = (Vector) all_nodes.get(node_name);
        for (Enumeration c = clusters.elements(); c.hasMoreElements(); ) {
          String cluster_name = (String) (c.nextElement());
          node_file.println("cluster = " + cluster_name);
        }
        node_file.close();
      } catch (IOException exc) {
        System.out.println("IOException:  " + exc);
        System.exit(-1);
      }
    }
  }
  public void doPost(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {

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

    String support = "support"; // valid username

    HttpSession session = null;
    session = req.getSession(false); // Get user's session object (no new one)
    if (session == null) {

      invalidUser(out); // Intruder - reject
      return;
    }

    String userName = (String) session.getAttribute("user"); // get username

    if (!userName.equals(support)) {

      invalidUser(out); // Intruder - reject
      return;
    }

    String action = "";
    if (req.getParameter("todo") != null) action = req.getParameter("todo");

    if (action.equals("update")) {

      doUpdate(out);
      return;
    }

    out.println("<p>Nothing to do.</p>todo=" + action);
  }
  public void doGet(HttpServletRequest req, HttpServletResponse res)
      throws IOException, ServletException {
    res.setContentType("text/html");
    try {
      PrintWriter pw = res.getWriter();
      pw.println("<html><head><TITLE>Web-Enabled Automated Manufacturing System</TITLE></head>");
      pw.println(
          "<body><br><br><br><form name=modifyuser method=post action='http://peers:8080/servlet/showUser')");
      v = U.allUsers();
      pw.println("<table align='center' border=0> <tr><td>");
      pw.println(
          "Select User Name To Modify</td><td><SELECT id=select1 name=uid style='HEIGHT: 22px; LEFT: 74px; TOP: 222px; WIDTH: 155px'>");
      pw.println("<OPTION selected value=''></OPTION>");
      for (i = 0; i < v.size(); i++)
        pw.println(
            "<OPTION value="
                + (String) v.elementAt(i)
                + ">"
                + (String) v.elementAt(i)
                + "</OPTION>");
      pw.println(
          "</SELECT></td></tr><tr><td></td><td><input type='submit' name='submit' value='Submit'></td></tr></table></form></body></html>");
      pw.flush();
      pw.close();

    } catch (Exception e) {
    }
  }
Esempio n. 5
0
  public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    PrintWriter writer = response.getWriter();
    HttpSession session = request.getSession();

    String username = request.getParameter("username");
    String password = request.getParameter("password");
    String type = request.getParameter("type");
    System.out.println(username + password + type);

    session.setAttribute("user", username);

    try {
      writer.println("<html>");
      writer.println("<body bgcolor=green>");
      writer.println("<center>");
      ps.setString(1, username);
      ps.setString(2, password);
      ps.setString(3, type);
      ResultSet rs = ps.executeQuery();

      if (rs.next()) {
        writer.println("<h1>LOGIN SUCCESSFUL</h1><br><br>");
        writer.println("<a href=account.html>click here to see your account</a>");
      } else {
        writer.println("<h1>LOGIN FAILED</h1><br><br>");
        writer.println("<a href=login.html>click here to login again</a>");
      }
      writer.println("</center>");
      writer.println("</body>");
      writer.println("</html>");
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
 /**
  * closes all files
  *
  * @author [email protected]
  * @date Thu Dec 1 22:00:05 2011
  */
 void closeFiles() {
   try {
     m_wrMkdirs.close();
     m_wrChmods.close();
   } catch (Exception e) {
     System.err.println("ERROR: failed to close files: " + e.toString());
   }
 }
Esempio n. 7
0
 /**
  * Utility method that returns a string which contains the stack trace of the given Exception
  * object.
  */
 public static String getStacktraceFromException(Throwable e) {
   ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
   PrintWriter writer = new PrintWriter(byteOut);
   e.printStackTrace(writer);
   writer.close();
   String message = new String(byteOut.toByteArray());
   return message;
 }
Esempio n. 8
0
 /**
  * ** Encodes the specified DBRecordKyes into XML and writes it to ** a specified PrintWriter
  * ** @param out The PrintWriter ** @param dbrk The list of DBRecordKeys
  */
 public static void printXML(PrintWriter out, DBRecordKey... dbrk) {
   if (out != null) {
     out.write("<" + DBFactory.TAG_RecordKeys + ">\n");
     for (int i = 0; i < dbrk.length; i++) {
       dbrk[i].printXML(out, 4);
     }
     out.write("</" + DBFactory.TAG_RecordKeys + ">\n");
     out.flush();
   }
 }
  public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    System.out.println("[Servlet3.doPost]");

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

    out.println("FILTER-REQUEST:" + request.getSession().getAttribute("FILTER-REQUEST"));
    out.println("FILTER-FORWARD:" + request.getSession().getAttribute("FILTER-FORWARD"));
    out.println("FILTER-INCLUDE:" + request.getSession().getAttribute("FILTER"));
  }
Esempio n. 10
0
  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    String users = getUsersFromDB();

    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    HtmlUtilities.printHeader(out, "Registered Users");
    out.println(users);
    HtmlUtilities.printActions(out);
    HtmlUtilities.printFooter(out);
  }
Esempio n. 11
0
  protected void processRequest(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();
    try {
      Class.forName("com.mysql.jdbc.Driver").newInstance();
      Connection con =
          DriverManager.getConnection(Utility.connection, Utility.username, Utility.password);

      String email = request.getParameter("email_id");

      String number = "";
      boolean exists = false;
      String user_name = "";
      int user_id = -1;
      String str1 = "SELECT USER_ID,NAME,PHONE_NUMBER FROM USERS WHERE EMAIL_ID=?";
      PreparedStatement prep1 = con.prepareStatement(str1);
      prep1.setString(1, email);
      ResultSet rs1 = prep1.executeQuery();
      if (rs1.next()) {
        exists = true;
        user_id = rs1.getInt("USER_ID");
        user_name = rs1.getString("NAME");
        number = rs1.getString("PHONE_NUMBER");
      }
      int verification = 0;
      JSONObject data = new JSONObject();
      if (exists) {
        verification = (int) (Math.random() * 9535641 % 999999);
        System.out.println("Number " + number + "\nVerification: " + verification);
        SMSProvider.sendSMS(
            number, "Your One Time Verification Code for PeopleConnect Is " + verification);
      }

      data.put("user_name", user_name);
      data.put("user_id", user_id);
      data.put("verification_code", "" + verification);
      data.put("phone_number", number);

      String toSend = data.toJSONString();
      out.print(toSend);
      System.out.println(toSend);

    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      out.close();
    }
  }
Esempio n. 12
0
  protected void processRequest(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();
    try {
      Class.forName("com.mysql.jdbc.Driver").newInstance();
      Connection con =
          DriverManager.getConnection(Utility.connection, Utility.username, Utility.password);

      int user_id = Integer.parseInt(request.getParameter("user_id"));
      int question_id = Integer.parseInt(request.getParameter("question_id"));
      int option = Integer.parseInt(request.getParameter("option"));

      System.out.println("uid: " + user_id + "\nquestion: " + question_id + "\noption: " + option);
      String str1 = "INSERT INTO VOTES(USER_ID, QUESTION_ID,OPTION_VOTED) VALUES (?,?,?)";
      PreparedStatement prep1 = con.prepareStatement(str1);
      prep1.setInt(1, user_id);
      prep1.setInt(3, option);
      prep1.setInt(2, question_id);
      prep1.execute();

      String str2 = "SELECT OPTION_" + option + " FROM ARCHIVE_VOTES WHERE QUESTION_ID=?";
      PreparedStatement prep2 = con.prepareStatement(str2);
      prep2.setInt(1, question_id);
      int count = 0;
      ResultSet rs2 = prep2.executeQuery();
      if (rs2.next()) {
        count = rs2.getInt("OPTION_" + option);
      }
      count++;
      String str3 = "UPDATE ARCHIVE_VOTES SET OPTION_" + option + "=? WHERE QUESTION_ID=?";
      PreparedStatement prep3 = con.prepareStatement(str3);
      prep3.setInt(1, count);
      prep3.setInt(2, question_id);
      prep3.executeUpdate();

      out.print("You Vote has been recorded! Thank you!");
      System.out.println(
          "Voted for question " + question_id + ", by user " + user_id + ", for option " + option);

    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      out.close();
    }
  }
Esempio n. 13
0
  // Write <Cluster>.ini file
  // Given Hashtable mapping cluster name to Vector of plugin names
  // <Cluster>.ini File format:
  // [ Cluster ]
  // uic = <Agentname>
  // cloned = false
  // [ Plugins ]
  // plugin = <pluginname>
  // ...
  //
  private void dumpClusterInfo(Hashtable all_clusters, String path) throws IOException {
    // Dump hashtable of clusters
    for (Enumeration e = all_clusters.keys(); e.hasMoreElements(); ) {
      String cluster_name = (String) e.nextElement();
      PrintWriter cluster_file;

      try {
        if (path != null) {
          cluster_file = createPrintWriter(path + File.separator + cluster_name + ".ini");
        } else {
          cluster_file = createPrintWriter(cluster_name + ".ini");
        }

        cluster_file.println("[ Cluster ]");
        cluster_file.println("uic = " + cluster_name);
        cluster_file.println("cloned = false\n");
        cluster_file.println("[ Plugins ]");
        Vector plugins = (Vector) (all_clusters.get(cluster_name));
        for (Enumeration p = plugins.elements(); p.hasMoreElements(); ) {
          String plugin = (String) (p.nextElement());
          cluster_file.println("plugin = " + plugin);
        }
        cluster_file.close();
      } catch (IOException exc) {
        System.out.println("IOException:  " + exc);
        System.exit(-1);
      }
    }
  }
Esempio n. 14
0
  public static void main(String args[]) {

    wmatrix wmatrix = new wmatrix();
    wmatrix.start();
    try {
      PrintWriter profilefout =
          new PrintWriter(
              new BufferedWriter(
                  new FileWriter(
                      "profile_"
                          + Data.kinease
                          + "_"
                          + Data.code
                          + "_"
                          + Data.windows_size
                          + ".csv")));

      profilefout.print("Position=");
      for (int j = 0; j < Data.windows_size; j++) {
        profilefout.print("," + (j - Data.windows_size / 2));
      }
      profilefout.println();

      for (int i = 0; i < 20; i++) {
        for (int j = 0; j < Data.windows_size; j++) {
          profilefout.print("," + wm[i][j]);
        }
        profilefout.println();
      }
      profilefout.close();

    } catch (IOException ex) {

    }
  }
Esempio n. 15
0
  public void doGet(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {

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

    String support = "support"; // valid username

    HttpSession session = null;
    session = req.getSession(false); // Get user's session object (no new one)

    if (session == null) {

      invalidUser(out); // Intruder - reject
      return;
    }

    String userName = (String) session.getAttribute("user"); // get username

    if (!userName.equals(support)) {

      invalidUser(out); // Intruder - reject
      return;
    }

    out.println("<HTML><HEAD><TITLE>Database Upgrade</TITLE></HEAD>");
    out.println("<BODY><CENTER>");
    out.println(
        "<BR><BR><H3>This job will check all clubs' session logs for caller=clubster.</H3>");
    out.println("<BR><BR>Click 'Continue' to start the job.");
    out.println("<BR><BR> <A HREF=\"/v5/servlet/Support_main\">Return</A><BR><BR>");

    out.println(
        "<form method=post><input type=submit value=\"Continue\" onclick=\"return confirm('Are you sure?')\">");
    out.println(" <input type=hidden value=\"update\" name=\"todo\"></form>");
    /*
    out.println("<form method=post><input type=submit value=\"  Test  \">");
    out.println(" <input type=hidden value=\"test\" name=\"todo\"></form>");
    *
    */

    out.println("</CENTER></BODY></HTML>");

    out.close();
  }
Esempio n. 16
0
  /**
   * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
   *
   * @param request servlet request
   * @param response servlet response
   * @throws ServletException if a servlet-specific error occurs
   * @throws IOException if an I/O error occurs
   */
  protected void processRequest(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();
    String username = request.getParameter("username");
    String password = request.getParameter("password");
    Statement stmt;
    ResultSet rs;
    Connection con = null;

    try {
      Class.forName("com.mysql.jdbc.Driver");
      String connectionUrl = "jdbc:mysql://localhost/myflickr?" + "user=root&password=123456";
      con = DriverManager.getConnection(connectionUrl);

      if (con != null) {
        System.out.println("connected to mysql");
      }
    } catch (SQLException e) {
      System.out.println("SQL Exception: " + e.toString());
    } catch (ClassNotFoundException cE) {
      System.out.println("Class Not Found Exception: " + cE.toString());
    }

    try {
      stmt = con.createStatement();

      System.out.println("SELECT * FROM flickrusers WHERE name='" + username + "'");
      rs = stmt.executeQuery("SELECT * FROM flickrusers WHERE name='" + username + "'");

      while (rs.next()) {

        if (rs.getObject(1).toString().equals(username)) {

          out.println("<h1>To username pou epileksate uparxei hdh</h1>");
          out.println("<a href=\"project3.html\">parakalw dokimaste kapoio allo.</a>");

          stmt.close();
          rs.close();
          return;
        }
      }
      stmt.close();
      rs.close();

      stmt = con.createStatement();

      if (!stmt.execute("INSERT INTO flickrusers VALUES('" + username + "', '" + password + "')")) {
        out.println("<h1>Your registration is completed  " + username + "</h1>");
        out.println("<a href=\"index.jsp\">go to the login menu</a>");
        registerListener.Register(username);
      } else {
        out.println("<h1>To username pou epileksate uparxei hdh</h1>");
        out.println("<a href=\"project3.html\">Register</a>");
      }
    } catch (SQLException e) {
      throw new ServletException("Servlet Could not display records.", e);
    }
  }
Esempio n. 17
0
  /** @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    // TODO Auto-generated method stub
    PrintWriter out = response.getWriter();
    String user_name = request.getParameter("username");
    String user_password = request.getParameter("password");
    if (user_name.equals("haobangpig") && user_password.equals("haobang123")) {
      response.sendRedirect("SuperUser.jsp");
    }
    try {
      Class.forName("com.mysql.jdbc.Driver");
      Connection con;
      Statement sql;
      ResultSet rs;
      con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "haobang");
      sql = con.createStatement();
      String sqlString =
          "select * from BBB_user where user_name='"
              + user_name
              + "'and user_password='******'";
      rs = sql.executeQuery(sqlString);
      if (rs.next()) {
        LoginBean nn = new LoginBean();
        nn.setUserName(user_name);
        nn.setPassword(user_password);
        HttpSession session = request.getSession();
        session.setAttribute("userName", user_name);
        response.sendRedirect("BBB_main.jsp");

      } else {
        String a = "BBB_index(system).jsp";
        out.println(
            "<!DOCTYPE html><html><body>Invalid password or username,please <a href="
                + a
                + ">try again</a></body></html>");
        // response.sendRedirect("BBB_index(system).jsp");
      }
    } catch (SQLException | ClassNotFoundException e1) {
      PrintWriter outq = response.getWriter();
      outq.println(e1);
    }
  }
 private void printOutLogs(Connection connection, PrintWriter out) throws SQLException {
   Statement select = connection.createStatement();
   ResultSet result = select.executeQuery("SELECT * FROM LOGGING ORDER BY DATE ASC");
   while (result.next()) {
     Timestamp date = result.getTimestamp("DATE");
     String ip = result.getString("IP");
     String url = result.getString("URL");
     out.println(date + "\t\t" + ip + "\t\t" + url);
   }
 }
  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    response.setContentType("text/html");

    PrintWriter out = response.getWriter();
    Connection conn = null;
    PreparedStatement pstmt = null;
    try {
      System.out.println("Enrollno: 130050131049");
      // STEP 2: Register JDBC driver
      Class.forName(JDBC_DRIVER);

      // STEP 3: Open a connection
      System.out.println("Connecting to a selected database...");
      conn = DriverManager.getConnection(DB_URL, USER, PASS);
      System.out.println("Connected database successfully...");

      // STEP 2: Executing query
      String sql = "SELECT * FROM logindetails WHERE name = ?";
      pstmt = conn.prepareStatement(sql);
      pstmt.setString(1, "Krut");

      ResultSet rs = pstmt.executeQuery();
      out.print("| <b>Name</b>| ");
      out.print("<b>Password</b>| ");
      out.println("</br>\n-------------------------------</br>");
      while (rs.next()) {
        out.println();
        out.print("| " + rs.getString(1));
        out.print("| " + rs.getString(2) + "|");
        out.println("</br>");
      }

    } catch (SQLException se) {
      // Handle errors for JDBC
      se.printStackTrace();
    } catch (Exception e) {
      // Handle errors for Class.forName
      e.printStackTrace();
    } finally {
      // finally block used to close resources
      try {
        if (pstmt != null) conn.close();
      } catch (SQLException se) {
      } // do nothing
      try {
        if (conn != null) conn.close();
      } catch (SQLException se) {
        se.printStackTrace();
      } // end finally try
    } // end try
  }
Esempio n. 20
0
 public void service(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException {
   response.setContentType("text/html");
   PrintWriter out = response.getWriter();
   try {
     String username = request.getParameter("t1");
     String password = request.getParameter("t2");
     String email = request.getParameter("t4");
     String college = request.getParameter("t5");
     String phone = request.getParameter("t6");
     String country = request.getParameter("t7");
     String languages = request.getParameter("t8");
     Class.forName("oracle.jdbc.driver.OracleDriver");
     Connection con =
         DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "system", "tiger");
     PreparedStatement pst = con.prepareStatement("insert into stu_tab values(?,?,?,?,?,?,?)");
     pst.setString(1, username);
     pst.setString(2, password);
     pst.setString(3, email);
     pst.setString(4, college);
     pst.setString(5, phone);
     pst.setString(6, country);
     pst.setString(7, languages);
     int i = pst.executeUpdate();
     if (i != 0) {
       out.println("<html><body align=center bgcolor=#C0C0C0 text=black>");
       out.println("<h3>!.. Registration Successful !..</h3>");
       out.println(
           "<a href=Slogin1.html style=text-decoration:none>click here</a>&nbsp;to go back to login page");
       out.println("</body></html>");
     } else {
       out.println("<html><body align=center bgcolor=#C0C0C0 text=black>");
       out.println("<h3>!.. Registration Failed !..</h3>");
       out.println(
           "<a href=Slogin1.html style=text-decoration:none>click here</a>&nbsp;to go back to login page");
       out.println("</body></html>");
     }
   } catch (Exception e) {
     out.println(e);
   }
 }
Esempio n. 21
0
 static void transCommit() {
   if (outputFiles == false) {
     try {
       conn.commit();
     } catch (SQLException se) {
       System.out.println(se.getMessage());
       transRollback();
     }
   } else {
     out.close();
   }
 }
Esempio n. 22
0
  private void invalidUser(PrintWriter out) {

    out.println(SystemUtils.HeadTitle("Access Error - Redirect"));
    out.println("<BODY><CENTER><img src=\"/v5/images/foretees.gif\"><BR>");
    out.println("<hr width=\"40%\">");
    out.println("<BR><H2>Access Error</H2><BR>");
    out.println("<BR><BR>Sorry, you must login before attempting to access these features.<BR>");
    out.println("<BR><BR>Please <A HREF=\"Logout\">login</A>");
    out.println("</CENTER></BODY></HTML>");
  }
Esempio n. 23
0
  public void handlePageBody(PageContext pc) throws ServletException, IOException {
    ServletContext context = pc.getServletContext();
    Document doc = null;
    try {
      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
      DocumentBuilder builder = factory.newDocumentBuilder();
      doc = builder.newDocument();
    } catch (Exception e) {
      throw new ServletException(e);
    }

    Element rootElem = doc.createElement("xaf");
    doc.appendChild(rootElem);

    try {
      DatabaseContextFactory.createCatalog(pc, rootElem);
      transform(pc, doc, ACE_CONFIG_ITEM_PROPBROWSERXSL);
    } catch (NamingException e) {
      PrintWriter out = pc.getResponse().getWriter();
      out.write(e.toString());
      e.printStackTrace(out);
    }
  }
Esempio n. 24
0
  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

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

    String dbUser = "******"; // enter your username here
    String dbPassword = "******"; // enter your password here

    try {
      OracleDataSource ods = new oracle.jdbc.pool.OracleDataSource();
      ods.setURL("jdbc:oracle:thin:@//w4111b.cs.columbia.edu:1521/ADB");
      ods.setUser(dbUser);
      ods.setPassword(dbPassword);

      Connection conn = ods.getConnection();

      String query = new String();
      Statement s = conn.createStatement();

      query = "select * from events";

      ResultSet r = s.executeQuery(query);
      while (r.next()) {
        out.println("Today's Date: " + r.getString(1) + " ");
      }
      r.close();
      s.close();

      conn.close();

    } catch (Exception e) {
      out.println("The database could not be accessed.<br>");
      out.println("More information is available as follows:<br>");
      e.printStackTrace(out);
    }
  } // end doGet method
 public void doPost(HttpServletRequest req, HttpServletResponse res)
     throws IOException, ServletException {
   res.setContentType("text/html");
   PrintWriter out = res.getWriter();
   out.println("vaishali mehta-130050131524");
   out.println("<html>");
   out.println("<body><table border='1'>");
   out.println("<th>name</th>");
   out.println("<th>password</th>");
   try {
     rs = stmt.executeQuery("select *from records");
     while (rs.next()) {
       tn = rs.getString("name");
       tp = rs.getString("password");
       out.println("<tr>");
       out.println("<td>" + tn + "</td>");
       out.println("<td>" + tp + "</td>");
       out.println("</tr>");
     }
   } catch (Exception e) {
     System.out.println(e);
   }
   out.println("</table></body></html>");
 }
  public void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException {
    try {

      res.setContentType("text/html");
      pw = res.getWriter();
      pw.println("<html>");
      pw.println("<head><title>Welcome Staff</title></head>");
      pw.println("<body>");
      pw.println("<b><marquee behavior=\"alternate\">Welcome Staff</marquee></b>");
      pw.println(
          "<p><a href=\"F:\\Studies\\Project\\com mini proj\\serv.html\"><img src=\"http://cdn.iconfinder.net/data/icons/duesseldorf/32/logout.png\" border=\"2\" alt=\"LogOut\" align=right /></a>");
      pw.println("<form method=\"get\" action=\"http://localhost:8080/servlet/EnterProject\">");
      pw.println(
          "<br /><p style=\"text-align: center\"><a name=\"cp\" value=\"ch\" href=\"http://localhost:8080/servlet/EnterProject\">Enter Project</a></p>");
      pw.println(
          "<br /><p style=\"text-align: center\"><a href=\"http://localhost:8080/servlet/AssignProject\">Assign Project</a></p>");

    } catch (NullPointerException e) {
      pw.println("Username or Password Cannot be Empty");
    } catch (Exception e1) {
      System.out.println(e1);
    }
    pw.println("</body></html>");
  }
Esempio n. 27
0
  @Override
  public void actionPerformed(ActionEvent e) {
    // TODO action
    Object obj = e.getSource();

    if (obj.equals(jtf) || obj.equals(textin)) {
      // name.setText(" 메시지 입력 ");
      pw.println(jtf.getText());
      jtf.setText("");
    } else if (obj.equals(serveropen)) {
      ServerOpen();
    } else if (obj.equals(clientin) || obj.equals(pi)) {
      ClientIn();
    } else if (obj.equals(conf)) {
      login();
    }
  }
  public BackupHdfs() {
    try {
      m_wrMkdirs = new PrintWriter(new BufferedWriter(new FileWriter("hdfs-mkdirs.sh")));
      m_wrMkdirs.println("hadoop fs -mkdir /mapred");
      m_wrMkdirs.println("hadoop fs -mkdir /mapred/system");

      m_wrChmods = new PrintWriter(new BufferedWriter(new FileWriter("hdfs-chmods.sh")));
      m_wrChmods.println("hadoop fs -chmod 775 /");
      m_wrChmods.println("hadoop fs -chown hdfs:hadoop /");
      m_wrChmods.println("hadoop fs -chown mapred:hadoop /mapred/system");
      m_wrChmods.println("hadoop fs -chmod 700 /mapred/system");
    } catch (IOException e) {
      System.err.println("ERROR: failed to open files for writing: " + e.toString());
    }
  }
Esempio n. 29
0
  @Override
  public void run() {
    // TODO Auto-generated method stub
    try {
      Socket s = new Socket(hostin, portin);
      InputStream ins = s.getInputStream();
      OutputStream os = s.getOutputStream();
      ir = new BufferedReader(new InputStreamReader(ins));
      pw = new PrintWriter(new OutputStreamWriter(os), true);

      pw.print(nick);
      while (true) {
        String line = ir.readLine();
        jta.append(line + "\n");
        jsp.getVerticalScrollBar().setValue(jsp.getVerticalScrollBar().getMaximum());
      }

    } catch (IOException e) {
      e.printStackTrace();
    }
  }
Esempio n. 30
0
 public void service(
     HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse)
     throws ServletException, IOException {
   String s = "";
   String s1 = "";
   String s2 = "";
   String s3 = "";
   String s4 = "";
   String s6 = "";
   String s7 = "";
   String s8 = "";
   String s9 = "";
   String s10 = "";
   String s11 = "";
   String s12 = "";
   String s13 = "";
   String s14 = "";
   String s16 = "";
   int i = 0;
   int j = 0;
   String s18 = "Level2";
   PrintWriter printwriter = httpservletresponse.getWriter();
   httpservletresponse.setContentType("text/html");
   HttpSession httpsession = httpservletrequest.getSession(true);
   String s17 = (String) httpsession.getValue("uid");
   String name = (String) httpsession.getValue("name");
   System.out.println("inside servicemethod");
   try {
     System.out.println("inside servicetry");
     rs =
         st.executeQuery(
             "select * from hdemp1 where levelname='"
                 + s18
                 + "'  and employeename='"
                 + name
                 + "'");
     if (rs.next()) {
       System.out.println("inside if");
       s = rs.getString(1);
       System.out.println("lnameis " + s);
       s1 = rs.getString(2);
       System.out.println("category id is " + s1);
       s2 = rs.getString(3);
       System.out.println("module id is " + s2);
       s3 = rs.getString(4);
       System.out.println("supportid is " + s3);
       String s5 = rs.getString(5);
       System.out.println("userid is " + s5);
       s6 = rs.getString(6);
       System.out.println("ename is:" + s6);
       s7 = rs.getString(7);
       System.out.println("address:" + s7);
       s8 = rs.getString(8);
       System.out.println("city is:" + s8);
       s9 = rs.getString(9);
       System.out.println("state is:" + s9);
       s10 = rs.getString(10);
       System.out.println("country is:" + s10);
       i = rs.getInt(11);
       System.out.println("zip is:" + i);
       j = rs.getInt(12);
       System.out.println("phone is:" + j);
       s11 = rs.getString(13);
       System.out.println("website is:" + s11);
       String s15 = rs.getString(14);
     }
     printwriter.println("<HTML>");
     printwriter.println("<HEAD>");
     printwriter.println("<TITLE></TITLE>");
     printwriter.println("</HEAD>");
     printwriter.println("<BODY>");
     printwriter.println("<form name=f action='./secondleveladminstrator.html'target='_parent'>");
     printwriter.println("<P align=center><FONT color=forestgreen ");
     printwriter.println(
         "size=6><STRONG>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
     printwriter.println("&nbsp;&nbsp; ");
     printwriter.println("<U><strong>Profile</strong></U></STRONG></FONT></P>");
     printwriter.println("<TABLE border=0 align=center cellPadding=1 cellSpacing=1 width=75%>");
     printwriter.println("<TR>");
     printwriter.println("<TD><strong>Level Name</strong></TD>");
     printwriter.println("<TD>" + s + "</TD></TR>");
     printwriter.println("<TR>");
     printwriter.println("<TD><strong>Category Id</strong></TD>");
     printwriter.println("<TD>" + s1 + "</TD></TR>");
     printwriter.println("<TR>");
     printwriter.println("<TD><strong>Module ID</strong></TD>");
     printwriter.println("<TD>" + s2 + "</TD></TR>");
     printwriter.println("<TR>");
     printwriter.println("<TD><strong>Support Id</strong></TD>");
     printwriter.println("<TD>" + s3 + "</TD></TR>");
     printwriter.println("<TR>");
     printwriter.println("<TD><strong>Employeename</strong></TD>");
     printwriter.println("<TD>" + s6 + "</TD></TR>");
     printwriter.println("<TR>");
     printwriter.println("<TD><strong>Address</strong></TD>");
     printwriter.println("<TD>" + s7 + "</TD></TR>");
     printwriter.println("<TR>");
     printwriter.println("<TD><strong>City</strong></TD>");
     printwriter.println("<TD>" + s8 + "</TD></TR>");
     printwriter.println("<TR>");
     printwriter.println("<TD><strong>State</strong></TD>");
     printwriter.println(" <TD>" + s9 + "</TD></TR>");
     printwriter.println("<TR>");
     printwriter.println("<TD><strong>Country</strong></TD>");
     printwriter.println(" <TD>" + s10 + "</TD></TR>");
     printwriter.println("<TR>");
     printwriter.println("<TD><strong>Pincode</strong></TD>");
     printwriter.println(" <TD>" + i + "</TD></TR>");
     printwriter.println("<TR>");
     printwriter.println("<TD><strong>Phone No</strong></TD>");
     printwriter.println("<TD>" + j + "</TD></TR>");
     printwriter.println("<TR>");
     printwriter.println(" <TD><strong>Email ID</strong></TD>");
     printwriter.println(" <TD>" + s11 + "</TD></TR>");
     printwriter.println("<TR>");
     printwriter.println(
         "<TD>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
     printwriter.println(
         "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
     printwriter.println("&nbsp;&nbsp;");
     printwriter.println("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ");
     printwriter.println("<INPUT id=submit1 name=submit1 type=submit value=Ok></TD>");
     printwriter.println(" <TD></TD></TR></TABLE>");
     printwriter.println("</form>");
     printwriter.println("</BODY>");
     printwriter.println("</HTML>");
   } catch (Exception exception) {
     System.out.println(exception);
   }
 }