diff options
author | Vitaly Takmazov | 2016-07-07 11:25:23 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2016-07-07 11:25:23 +0300 |
commit | a93c85c5ea1bf6683f604bef2608053957577ff0 (patch) | |
tree | f80998a4cf339a2b85cd5f095f4386de9d46597b /src/main/java/com/juick/http/www/Settings.java | |
parent | 3e48ba7c9cae9027b0a045aa25ae40b533518865 (diff) | |
parent | 857a930d31c425185c9b9405f5a7820e6cec9491 (diff) |
merge rebase_all
Diffstat (limited to 'src/main/java/com/juick/http/www/Settings.java')
-rw-r--r-- | src/main/java/com/juick/http/www/Settings.java | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/src/main/java/com/juick/http/www/Settings.java b/src/main/java/com/juick/http/www/Settings.java index de37bdd0..54ee0ee9 100644 --- a/src/main/java/com/juick/http/www/Settings.java +++ b/src/main/java/com/juick/http/www/Settings.java @@ -17,15 +17,14 @@ */ package com.juick.http.www; -import java.io.IOException; -import java.io.PrintWriter; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.SQLException; +import org.springframework.jdbc.core.JdbcTemplate; + import javax.servlet.ServletException; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.PrintWriter; /** * @@ -33,12 +32,11 @@ import javax.servlet.http.HttpServletResponse; */ public class Settings { - protected void doGet(Connection sql, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + protected void doGet(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { com.juick.User visitor = Utils.getVisitorUser(sql, request, response); response.setContentType("text/html; charset=UTF-8"); - PrintWriter out = response.getWriter(); - try { + try (PrintWriter out = response.getWriter()) { PageTemplates.pageHead(out, "Логин", ""); PageTemplates.pageNavigation(out, visitor, null); @@ -56,12 +54,10 @@ public class Settings { PageTemplates.pageFooter(request, out, visitor, false); PageTemplates.pageEnd(out); - } finally { - out.close(); } } - protected void doPost(Connection sql, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + protected void doPost(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String username = request.getParameter("username"); String password = request.getParameter("password"); if (username == null || password == null || username.length() > 32 || password.isEmpty()) { @@ -79,16 +75,7 @@ public class Settings { if (uid > 0) { - PreparedStatement stmt = null; - try { - stmt = sql.prepareStatement("DELETE FROM logins WHERE user_id=?"); - stmt.setInt(1, uid); - stmt.executeUpdate(); - } catch (SQLException e) { - System.err.println(e); - } finally { - Utils.finishSQL(null, stmt); - } + throw new IOException("Settings"); } String referer = request.getHeader("Referer"); |