Esempio n. 1
0
 private int getProjectIdFromSessionAttributes(HttpSession session) {
   String sessionUsername = (String) session.getAttribute(Attribute.USERNAME.toString());
   int accountId = DatabaseApi.getAccountId(sessionUsername);
   String sessionProjectName = (String) session.getAttribute(Attribute.PROJECT_NAME.toString());
   int projectId = DatabaseApi.getProjectId(sessionProjectName, accountId);
   return projectId;
 }
Esempio n. 2
0
 // http://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/Servlet-Tutorial-Form-Data.html
 @Override
 protected void doGet(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException {
   log.info("The servlet is responding to an HTTP GET request");
   response.setContentType("text/html");
   HttpSession session = request.getSession();
   String projectName = request.getParameter("projectName");
   int accountId =
       DatabaseApi.getAccountId((String) session.getAttribute(Attribute.USERNAME.toString()));
   if (projectName != null
       && Security.isSafeProjectName(projectName)
       && DatabaseApi.projectExists(projectName, accountId)) { // Short-circuiting
     session.setAttribute(Attribute.PROJECT_NAME.toString(), projectName);
     response.sendRedirect("editor.jsp");
   } else {
     response.sendRedirect("projects.jsp");
   }
   PrintWriter out = response.getWriter();
   out.println("File uploaded. Please close this window and refresh the editor page.");
   out.flush();
   out.close();
 }