aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/http/www/Errors.java
blob: f8c347b7944082106444a58e88eb73c8fa4a7ada (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package com.juick.http.www;

import org.springframework.jdbc.core.JdbcTemplate;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author ugnich
 */
public class Errors {

    public static String tagsHTML = null;

    public static void doGet404(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        com.juick.User visitor = Utils.getVisitorUser(sql, request, response);

        if (tagsHTML == null) {
            tagsHTML = PageTemplates.getPopularTags(sql, 80);
        }

        response.setStatus(404);
        response.setContentType("text/html; charset=UTF-8");
        PrintWriter out = response.getWriter();
        try {
            PageTemplates.pageHead(out, "404 Страница не найдена", null);
            PageTemplates.pageNavigation(out, visitor, null);
            PageTemplates.pageHomeColumn(out, sql, visitor);

            out.println("<section id=\"content\">");
            out.println("<h1>Страница не найдена</h1>");
            out.println("<p>Сожалеем, но страницу с этим адресом удалил её автор, либо её никогда не существовало.</p>");
            out.println("</section>");

            PageTemplates.pageFooter(request, out, visitor, false);
            PageTemplates.pageEnd(out);
        } finally {
            out.close();
        }
    }
}