throws ServletException, IOException {
X509Certificate[] cert = (X509Certificate[]) req
.getAttribute("javax.servlet.request.X509Certificate");
- HttpSession hs = req.getSession(false);
- if (hs == null || hs.getAttribute(LOGGEDIN) == null) {
+ HttpSession hs = req.getSession();
+ if (hs.getAttribute(LOGGEDIN) == null) {
if (cert != null) {
tryAuthWithCertificate(req, cert[0]);
- hs = req.getSession(false);
+ hs = req.getSession();
}
}
- if (hs != null && ((Boolean) hs.getAttribute("loggedin"))
+ if (hs.getAttribute("loggedin") != null
&& req.getPathInfo().equals("/login")) {
resp.sendRedirect("/");
return;
return;
}
- if ((hs == null || !((Boolean) hs.getAttribute("loggedin")))
+ if (hs.getAttribute("loggedin") == null
&& !"/login".equals(req.getPathInfo())) {
System.out.println(req.getPathInfo());
resp.sendRedirect("/login");
String b0 = baseTemplate[0];
Page p = pages.get(req.getPathInfo());
b0 = makeDynTempl(b0, p);
- resp.setContentType("text/html");
+ resp.setContentType("text/html; charset=utf-8");
resp.getWriter().print(b0);
if (hs != null && hs.getAttribute(LOGGEDIN) != null) {
resp.getWriter().println(
"Hi " + ((User) hs.getAttribute(USER)).getFname());
}
- p.doGet(req, resp);
+ if (req.getMethod().equals("POST")) {
+ p.doPost(req, resp);
+ } else {
+ p.doGet(req, resp);
+ }
String b1 = baseTemplate[1];
b1 = makeDynTempl(b1, p);
resp.getWriter().print(b1);