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); } }
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) { } }
// 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); } } }
// 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); } } }
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(); } }
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")); }
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 }
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) { } }
/** @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 { 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); }
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>"); }
public void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { res.setContentType("text/html"); hs = req.getSession(true); PrintWriter pw = res.getWriter(); uid = req.getParameter("did"); if (!uid.equals("")) { v = D.getDealer(uid); pw.println( "<html><head><TITLE>Web-Enabled Automated Manufacturing System</TITLE><script language=javascript>function set() {"); pw.println( "document.deldealer.select1.value='" + (String) v.elementAt(4) + "'} </script></head><P align=center><FONT color=deepskyblue size=4><STRONG>MODIFY DEALER </STRONG></FONT></P> "); pw.println( "<body onLoad=set()><br><br><form name=deldealer method=post action='http://peers:8080/servlet/DelDealer'>"); pw.println( "<center><TABLE border=0 cellPadding=1 cellSpacing=1 width='75%' style='HEIGHT: 147px; WIDTH: 248px'>"); pw.println( "<TR><TD>DealerId </TD><TD><INPUT id=text1 name=did value=" + (String) v.elementAt(0) + "></TD></TR>"); pw.println( "<TR><TD>DealerName</TD><TD><INPUT id=text2 name=dname value=" + (String) v.elementAt(1) + " ></TD></TR><TR><TD>DealerAddress</TD>"); pw.println( "<TD><INPUT id=text2 type=text name=daddr value=" + (String) v.elementAt(2) + "></TD></TR><TR><TD>CreditLimit</TD><TD><INPUT id=text4 name=cl value=" + v.get(3).toString()); pw.println( "></TD></TR><TR><TD><P>Staus</P></TD><td><SELECT id=select1 name=status style='HEIGHT: 22px; LEFT: 1px; TOP: 1px; WIDTH: 136px'> <OPTION "); pw.println( "selected value=''></OPTION><OPTION value=Active>Active</OPTION><OPTION value=Inactive>Inactive</OPTION></SELECT><INPUT id=submit1 name=submit1 style='LEFT: 151px; TOP: 318px' type=submit value=Delete></TD></TR>"); pw.println("</table></center></form></body></html>"); pw.flush(); pw.close(); } }
/** * 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); } }
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 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> 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> to go back to login page"); out.println("</body></html>"); } } catch (Exception e) { out.println(e); } }
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>"); }
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(); }
public void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { res.setContentType("text/html"); PrintWriter pw = res.getWriter(); PR.deleteProduct(req.getParameter("prid")); pw.println("<html><head><TITLE>Web-Enabled Automated Manufacturing System</TITLE></head>"); pw.println("<table align='center' border=0>"); pw.println("<tr col span=2><th>Web-Enabled Automated Manufacturing Process</th></tr>"); pw.println("<tr><td>Product ID:</td><td>" + req.getParameter("prid") + "</td></tr>"); pw.println("<tr><td>Product data is deleted Click on OK to Continue</td></tr>"); pw.println( "<tr><td align=center><a href='http://peers:8080/servlet/deleteProduct' target='main'>OK</a></td>"); pw.println("<td></td></tr>"); pw.println("</table></form></body></html>"); pw.flush(); pw.close(); }
@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 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 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()); } }
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> "); printwriter.println(" "); 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> "); printwriter.println( " "); printwriter.println(" "); printwriter.println(" "); 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); } }
// ***************************************************** // Process the initial request from Proshop_main // ***************************************************** // @SuppressWarnings("deprecation") public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { // // Prevent caching so sessions are not mangled // resp.setHeader("Pragma", "no-cache"); // for HTTP 1.0 resp.setHeader("Cache-Control", "no-store, no-cache, must-revalidate"); // for HTTP 1.1 resp.setDateHeader("Expires", 0); // prevents caching at the proxy server resp.setContentType("text/html"); PrintWriter out = resp.getWriter(); HttpSession session = SystemUtils.verifyPro(req, out); // check for intruder if (session == null) { return; } String club = (String) session.getAttribute("club"); // get club name String templott = (String) session.getAttribute("lottery"); // get lottery support indicator int lottery = Integer.parseInt(templott); // // Call is to display the new features page. // // Display a page to provide a link to the new feature page // out.println("<html><head>"); out.println("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1252\">"); out.println("<meta http-equiv=\"Content-Language\" content=\"en-us\">"); out.println("<title> \"ForeTees Proshop Announcement Page\"</title>"); // out.println("<link rel=\"stylesheet\" href=\"/" +rev+ "/web utilities/foretees.css\" // type=\"text/css\"></link>"); out.println( "<script language=\"JavaScript\" src=\"/" + rev + "/web utilities/foretees.js\"></script>"); out.println("</head>"); out.println("<body bgcolor=\"#FFFFFF\" text=\"#000000\">"); SystemUtils.getProshopSubMenu(req, out, lottery); File f; FileReader fr; BufferedReader br; String tmp = ""; String path = ""; try { path = req.getRealPath(""); tmp = "/proshop_features.htm"; // "/" +rev+ f = new File(path + tmp); fr = new FileReader(f); br = new BufferedReader(fr); if (!f.isFile()) { // do nothing } } catch (FileNotFoundException e) { out.println("<br><br><p align=center>Missing New Features Page.</p>"); out.println("</BODY></HTML>"); out.close(); return; } catch (SecurityException se) { out.println("<br><br><p align=center>Access Denied.</p>"); out.println("</BODY></HTML>"); out.close(); return; } while ((tmp = br.readLine()) != null) out.println(tmp); br.close(); out.println("</BODY></HTML>"); out.close(); } // end of doGet
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); HttpSession session = request.getSession(true); try { Object accountObject = session.getValue(ACCOUNT); // If no account object was put in the session, or // if one exists but it is not a hashtable, then // redirect the user to the original login page if (accountObject == null) throw new RuntimeException("You need to log in to use this service!"); if (!(accountObject instanceof Hashtable)) throw new RuntimeException("You need to log in to use this service!"); Hashtable account = (Hashtable) accountObject; String userName = (String) account.get("name"); ////////////////////////////////////////////// // Display Messages for the user who logged in ////////////////////////////////////////////// out.println("<HTML>"); out.println("<HEAD>"); out.println("<TITLE>Contacts for " + userName + "</TITLE>"); out.println("</HEAD>"); out.println("<BODY BGCOLOR='#EFEFEF'>"); out.println("<H3>Welcome " + userName + "</H3>"); out.println("<CENTER>"); Connection con = null; Statement stmt = null; ResultSet rs = null; try { Class.forName("com.mysql.jdbc.Driver").newInstance(); con = DriverManager.getConnection( "jdbc:mysql://localhost/contacts?user=kareena&password=kapoor"); stmt = con.createStatement(); rs = stmt.executeQuery( "SELECT * FROM contacts WHERE userName='******' ORDER BY contactID"); out.println("<form name='deleteContactsForm' method='post' action='deleteContact'>"); out.println("<TABLE BGCOLOR='#EFEFFF' CELLPADDING='2' CELLSPACING='4' BORDER='1'>"); out.println("<TR BGCOLOR='#D6DFFF'>"); out.println("<TD ALIGN='center'><B>Contact ID</B></TD>"); out.println("<TD ALIGN='center'><B>Contact Name</B></TD>"); out.println("<TD ALIGN='center'><B>Comment</B></TD>"); out.println("<TD ALIGN='center'><B>Date</B></TD>"); out.println("<TD ALIGN='center'><B>Delete Contacts</B></TD>"); out.println("</TR>"); int nRows = 0; while (rs.next()) { nRows++; String messageID = rs.getString("contactID"); String fromUser = rs.getString("contactName"); String message = rs.getString("comments"); String messageDate = rs.getString("dateAdded"); out.println("<TR>"); out.println("<TD>" + messageID + "</TD>"); out.println("<TD>" + fromUser + "</TD>"); out.println("<TD>" + message + "</TD>"); out.println("<TD>" + messageDate + "</TD>"); out.println( "<TD><input type='checkbox' name='msgList' value='" + messageID + "'> Delete</TD>"); out.println("</TR>"); } out.println("<TR>"); out.println( "<TD COLSPAN='6' ALIGN='center'><input type='submit' value='Delete Selected Contacts'></TD>"); out.println("</TR>"); out.println("</TABLE>"); out.println("</FORM>"); } catch (Exception e) { out.println("Could not connect to the users database.<P>"); out.println("The error message was"); out.println("<PRE>"); out.println(e.getMessage()); out.println("</PRE>"); } finally { if (rs != null) { try { rs.close(); } catch (SQLException ignore) { } } if (stmt != null) { try { stmt.close(); } catch (SQLException ignore) { } } if (con != null) { try { con.close(); } catch (SQLException ignore) { } } } out.println("</CENTER>"); out.println("</BODY>"); out.println("</HTML>"); } catch (RuntimeException e) { out.println("<script language=\"javascript\">"); out.println("alert(\"You need to log in to use this service!\");"); out.println("</script>"); out.println("<a href='index.html'>Click Here</a> to go to the main page.<br><br>"); out.println( "Or Click on the button to exit<FORM><INPUT onClick=\"javascipt:window.close()\" TYPE=\"BUTTON\" VALUE=\"Close Browser\" TITLE=\"Click here to close window\" NAME=\"CloseWindow\" STYLE=\"font-family:Verdana, Arial, Helvetica; font-size:smaller; font-weight:bold\"></FORM>"); log(e.getMessage()); return; } }
public synchronized void service(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { HttpSession dbSession = request.getSession(); JspFactory _jspxFactory = JspFactory.getDefaultFactory(); PageContext pageContext = _jspxFactory.getPageContext(this, request, response, "", true, 8192, true); ServletContext dbApplication = dbSession.getServletContext(); PrintWriter out = response.getWriter(); ServletContext application; HttpSession session = request.getSession(); nseer_db_backup1 finance_db = new nseer_db_backup1(dbApplication); ValidataNumber validata = new ValidataNumber(); try { if (finance_db.conn((String) dbSession.getAttribute("unit_db_name"))) { String file_id = request.getParameter("file_id"); String balance_sum = request.getParameter("balance_sum"); String balance_sum1 = request.getParameter("balance_sum1"); if (validata.validata(balance_sum) && validata.validata(balance_sum1)) { String sql2 = "select id from finance_bill where tag='1' and file_id='" + file_id + "'"; ResultSet rs2 = finance_db.executeQuery(sql2); String sql = ""; if (rs2.next()) { sql = "update finance_bill set debit_subtotal='" + balance_sum1 + "' where tag='1' and file_id='" + file_id + "'"; } else { sql = "insert into finance_bill(debit_subtotal,file_id,tag) values('" + balance_sum1 + "','" + file_id + "','1')"; } finance_db.executeUpdate(sql); sql2 = "select id from finance_voucher where account_period='18' and chain_id='" + file_id + "'"; rs2 = finance_db.executeQuery(sql2); if (rs2.next()) { sql = "update finance_voucher set debit_subtotal='" + balance_sum + "' where account_period='18' and chain_id='" + file_id + "'"; } else { sql = "insert into finance_voucher(debit_subtotal,chain_id,account_period) values('" + balance_sum + "','" + file_id + "','18')"; } finance_db.executeUpdate(sql); finance_db.commit(); finance_db.close(); } else { out.println("1"); } } else { response.sendRedirect("error_conn.htm"); } } catch (Exception ex) { ex.printStackTrace(); } }
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(" "); out.println(" "); out.println("<input type=text name=\"userid\">"); out.println("<br><br>Enter your Credit card no:"); out.println(" "); out.println("<input type=text name=\"cardno\"><br><br>"); out.println("Enter your Bank name:"); out.println(" "); out.println("<input type=text name=\"bankname\"><br><br>"); out.println("Bill amount:</b>"); out.println( " "); out.println(" Rs. "); out.println("<input type=text name=\"billamt\" value=" + cost + "> /-"); out.println("</font><br><br><br><br>"); out.println("<input type=submit value=\"submit\">"); out.println("</form></body></html>"); } // service
public void doGet(HttpServletRequest request, HttpServletResponse response) { response.setContentType("text/html"); PrintWriter webPageOutput = null; try { webPageOutput = response.getWriter(); } catch (IOException error) { Routines.writeToLog(servletName, "getWriter error : " + error, false, context); } HttpSession session = request.getSession(); session.setAttribute("redirect", request.getRequestURL() + "?" + request.getQueryString()); Connection database = null; try { database = pool.getConnection(servletName); } catch (SQLException error) { Routines.writeToLog(servletName, "Unable to connect to database : " + error, false, context); } if (Routines.loginCheck(true, request, response, database, context)) { return; } String server = context.getInitParameter("server"); boolean liveSever = false; if (server == null) { server = ""; } if (server.equals("live")) { response.setHeader("Refresh", "60"); } Routines.WriteHTMLHead( "View System Log", // title false, // showMenu 13, // menuHighLight false, // seasonsMenu false, // weeksMenu false, // scores false, // standings false, // gameCenter false, // schedules false, // previews false, // teamCenter false, // draft database, // database request, // request response, // response webPageOutput, // webPageOutput context); // context webPageOutput.println("<CENTER>"); webPageOutput.println( "<IMG SRC=\"../Images/Admin.gif\"" + " WIDTH='125' HEIGHT='115' ALT='Admin'>"); webPageOutput.println("</CENTER>"); pool.returnConnection(database); webPageOutput.println(Routines.spaceLines(1)); Routines.tableStart(false, webPageOutput); Routines.tableHeader("System Log", 0, webPageOutput); Routines.tableDataStart(true, false, false, true, true, 0, 0, "scoresrow", webPageOutput); boolean firstLine = true; int numOfLines = 0; try { String file = context.getRealPath("/"); FileReader logFile = new FileReader(file + "/Data/log.txt"); BufferedReader logFileBuffer = new BufferedReader(logFile); boolean endOfFile = false; while (!endOfFile) { String logFileText = logFileBuffer.readLine(); if (logFileText == null) { endOfFile = true; } else { if (firstLine) { firstLine = false; } else { webPageOutput.println(Routines.spaceLines(1)); } numOfLines++; webPageOutput.println(logFileText); } } logFileBuffer.close(); } catch (IOException error) { Routines.writeToLog(servletName, "Problem with log file : " + error, false, context); } Routines.tableDataEnd(false, true, true, webPageOutput); Routines.tableEnd(webPageOutput); if (numOfLines < 20) { webPageOutput.println(Routines.spaceLines(20 - numOfLines)); } Routines.WriteHTMLTail(request, response, webPageOutput); }
/** * 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; if (username == null || password == null) { out.println("<h1>Invalid Register Request</h1>"); out.println("<a href=\"register.html\">Register</a>"); return; } Connection con = null; try { Class.forName("com.mysql.jdbc.Driver"); String connectionUrl = "jdbc:mysql://localhost/project3?" + "user=root&password=marouli"; con = DriverManager.getConnection(connectionUrl); if (con != null) { System.out.println("Ola ok me 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(); rs = stmt.executeQuery("SELECT * FROM users WHERE username='******'"); if (rs.next()) { out.println("<h1>Username exists</h1>"); out.println("<a href=\"register.html\">Register</a>"); stmt.close(); rs.close(); con.close(); return; } stmt.close(); rs.close(); stmt = con.createStatement(); if (!stmt.execute("INSERT INTO users VALUES('" + username + "', '" + password + "')")) { out.println("<h1>You are now registered " + username + "</h1>"); out.println("<a href=\"index.jsp\">Login</a>"); int i; for (i = 0; i < listeners.size(); i++) listeners.get(i).UserRegistered(username); } else { out.println("<h1>Could not add your username to the db</h1>"); out.println("<a href=\"register.html\">Register</a>"); } stmt.close(); con.close(); } catch (SQLException e) { throw new ServletException("Servlet Could not display records.", e); } }