- private String makeDynTempl(String in, Page p) {
- int year = Calendar.getInstance().get(Calendar.YEAR);
- in = in.replaceAll("\\$title\\$", p.getTitle());
- in = in.replaceAll("\\$year\\$", year + "");
- return in;
- }
- private void authWithUnpw(HttpServletRequest req) {
- String un = req.getParameter("username");
- String pw = req.getParameter("password");
- try {
- PreparedStatement ps = DatabaseConnection.getInstance().prepare(
- "SELECT `password`, `id` FROM `users` WHERE `email`=?");
- ps.setString(1, un);
- ResultSet rs = ps.executeQuery();
- if (rs.next()) {
- if (PasswordHash.verifyHash(pw, rs.getString(1))) {
- HttpSession hs = req.getSession();
- hs.setAttribute(LOGGEDIN, true);
- hs.setAttribute(USER, new User(rs.getInt(2)));
- }
- }
- rs.close();
- } catch (SQLException e) {
- e.printStackTrace();
+ private Page getPage(String pathInfo) {
+ if (pathInfo.endsWith("/") && !pathInfo.equals("/")) {
+ pathInfo = pathInfo.substring(0, pathInfo.length() - 1);