aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/http/www/Settings.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-06-27 10:39:24 +0300
committerGravatar Vitaly Takmazov2016-06-27 10:39:24 +0300
commit0d93073c6988a22246db61a59b97c2fd7c9f462b (patch)
treed5f27cdb9a4fe51690f7af067608a9bee62087e3 /src/main/java/com/juick/http/www/Settings.java
parent2d7f61242de54b0c0670bac1953e45ee18d9ecec (diff)
parent53fb0b3e0e790df007a198deef21c115ed236b3e (diff)
merge
Diffstat (limited to 'src/main/java/com/juick/http/www/Settings.java')
-rw-r--r--src/main/java/com/juick/http/www/Settings.java22
1 files changed, 6 insertions, 16 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..f197ff12 100644
--- a/src/main/java/com/juick/http/www/Settings.java
+++ b/src/main/java/com/juick/http/www/Settings.java
@@ -17,6 +17,8 @@
*/
package com.juick.http.www;
+import org.springframework.jdbc.core.JdbcTemplate;
+
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
@@ -33,12 +35,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 +57,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 +78,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");