diff options
author | Ugnich Anton | 2014-03-08 17:34:53 +0700 |
---|---|---|
committer | Ugnich Anton | 2014-03-08 17:34:53 +0700 |
commit | d39d1bf69b4de2d8f12d4a7547cd9f7938dc1a52 (patch) | |
tree | e0af6f56bce6f4286407855add3709ef3850b147 /src/java/com/juick/http/www/Errors.java | |
parent | 88f3693c53e70ad064ccc1466ddf27cae98db49a (diff) |
Errors.doGet404
Diffstat (limited to 'src/java/com/juick/http/www/Errors.java')
-rw-r--r-- | src/java/com/juick/http/www/Errors.java | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/java/com/juick/http/www/Errors.java b/src/java/com/juick/http/www/Errors.java new file mode 100644 index 00000000..c1ffc2e8 --- /dev/null +++ b/src/java/com/juick/http/www/Errors.java @@ -0,0 +1,47 @@ +package com.juick.http.www; + +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(Connection 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); + + out.println("<aside id=\"column\">"); + out.println(" <p class=\"tags\">" + tagsHTML + "</p>"); + out.println("</aside>"); + + 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(); + } + } +} |