import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import java.io.IOException; import java.io.PrintWriter; @javax.servlet.annotation.WebServlet(name = "Controller") public class Controller extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(); Object token = session.getAttribute("token"); if (token == null) { request.getRequestDispatcher("/login.jsp").forward(request, response); return; } // TODO : redirect to home } public static String formatUrl(String url) { if (url.charAt(url.length()-1) == '/') { url = url.substring(0, url.length()-1); } return url; } }