Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.87 KB | None | 0 0
  1. `<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
  2. <%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
  3. <%@page import="java.sql.*" %>
  4. <%@page import="com.mysql.jdbc.PreparedStatement" %>
  5. <%@page import="com.mysql.jdbc.Connection" %>
  6. <%@ page import="java.util.Enumeration" %>
  7. <%@ page import="java.io.PrintWriter" %>
  8.  
  9. <fmt:requestEncoding value="UTF-8" />
  10. <%request.setCharacterEncoding("UTF-8");response.setContentType ("text/html; charset=UTF-8"); %>
  11.  
  12.  
  13. <?xml version="1.0" encoding="UTF-8"?>
  14. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  15. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fi">
  16. <head>
  17. <meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
  18. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  19. <title>JSP</title>
  20. </head>
  21. <body>
  22. <%@ page contentType="text/html; charset=UTF-8" %>
  23. <%
  24. try {
  25. response.setContentType ("text/html; charset=UTF-8");
  26. request.setCharacterEncoding ("UTF-8");
  27. response.setCharacterEncoding("UTF-8");
  28. Connection con, conn;
  29. try {
  30. Class.forName("com.mysql.jdbc.Driver");
  31. } catch (ClassNotFoundException e) {
  32. e.printStackTrace();
  33. }
  34.  
  35.  
  36. conn = (Connection) DriverManager.getConnection("jdbc:mysql:localhost:3306/schedule", "sch", "sch");
  37. PreparedStatement zxc = (PreparedStatement) conn.prepareStatement("SET NAMES utf8");
  38.  
  39. //zx.setString(1, login);
  40. zxc.execute();
  41. zxc.close();
  42. String dat = request.getParameter("btn");
  43. String day_num = request.getParameter("day_num" + dat.substring(dat.length()-1, dat.length()));
  44. String first = request.getParameter("first" + dat.substring(dat.length()-1, dat.length()));
  45. String second = request.getParameter("second" + dat.substring(dat.length()-1, dat.length()));
  46. String third = request.getParameter("third" + dat.substring(dat.length()-1, dat.length()));
  47. String fourth = request.getParameter("fourth" + dat.substring(dat.length()-1, dat.length()));
  48. String fifth = request.getParameter("fifth" + dat.substring(dat.length()-1, dat.length()));
  49. String sixth = request.getParameter("sixth" + dat.substring(dat.length()-1, dat.length()));
  50. String seventh = request.getParameter("seventh" + dat.substring(dat.length()-1, dat.length()));
  51. String group = dat.substring(0, dat.length()-1);
  52. out.println(group);
  53.  
  54.  
  55.  
  56. String bad_redirectURL = "login.jsp";
  57. String good_redirectURL = "tables.jsp?group=" + dat.substring(0, dat.length()-2);
  58.  
  59.  
  60. con = (Connection) DriverManager.getConnection("jdbc:mysql:localhost:3306/schedule", "user_creator", "user_creator");
  61.  
  62. Statement rs = con.createStatement();
  63. rs.executeQuery("SET NAMES 'UTF8'");
  64. rs.close();
  65.  
  66.  
  67. String query = "UPDATE " + group +" SET first = ?, second = ?, third = ?, fourth = ?, fifth = ?, sixth = ?, seventh = ? WHERE day_num = ?;";
  68.  
  69.  
  70.  
  71.  
  72. PreparedStatement ps = (PreparedStatement) con.prepareStatement(query);
  73.  
  74.  
  75.  
  76.  
  77. ps.setString(1, first);
  78. ps.setString(2, second);
  79. ps.setString(3, third);
  80. ps.setString(4, fourth);
  81. ps.setString(5, fifth);
  82. ps.setString(6, sixth);
  83. ps.setString(7, seventh);
  84. ps.setString(8, day_num);
  85. out.println(ps.toString());
  86.  
  87.  
  88.  
  89. ps.execute();
  90.  
  91. response.sendRedirect(good_redirectURL);
  92.  
  93.  
  94.  
  95. } catch (NullPointerException | SQLException e) {
  96. e.printStackTrace();
  97. }
  98. %>
  99. </body>
  100. </html>>`
  101.  
  102. <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8"/>
  103.  
  104. <jsp-config>
  105. <jsp-property-group>
  106. <url-pattern>*.jsp</url-pattern>
  107. <page-encoding>UTF-8</page-encoding>
  108. </jsp-property-group>
  109. </jsp-config>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement