aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/http/www/Settings.java
diff options
context:
space:
mode:
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");