protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String pathInfo = req.getPathInfo(); if (pathInfo.equals("/")) { HttpSession session = req.getSession(); if (session == null) { resp.setStatus(401); return; } String username = (String) session.getAttribute("username"); if (username == null) { resp.setStatus(401); return; } Map userMap = loadUserSettingsMap(username); if (userMap == null) { resp.setStatus(401); return; } Enumeration parameterNames = req.getParameterNames(); while (parameterNames.hasMoreElements()) { String parameterName = (String) parameterNames.nextElement(); userMap.put(parameterName, req.getParameter(parameterName)); } saveUserSettingsMap(username, userMap); return; } super.doPost(req, resp); }
@Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { super.doPost(req, resp); service(req, resp); log("method POST"); }
/** @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String p; if ((p = request.getParameter("delete_username")) != null) { User u = userRepo.getByPK(p); if (u != null && u.equals(request.getUserPrincipal())) { userRepo.deleteUser(u); this.getServletContext().getRequestDispatcher("/users").forward(request, response); } } else if ((p = request.getParameter("save_username")) != null) { User u = userRepo.getByPK(p); if (u != null && u.equals(request.getUserPrincipal())) { u.setEmail(request.getParameter("Email")); u.setWoonplaats(request.getParameter("Woonplaats")); u.setPassword(request.getParameter("Password")); userRepo.saveUser(u); } } else { super.doPost(request, response); } }
@Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { // TODO Auto-generated method stub super.doPost(req, resp); }
@Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { super.doPost(req, resp); }
@Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { logger.info("post: " + req.getQueryString()); String sessionId = req.getParameter("sessionId"); if (!Utils.isNullOrEmpty(sessionId)) { Session session = getSessionCache().getSessionForSessionId(sessionId); if (session.getUserProfile() != null) { String uploadType = req.getParameter("upload"); logger.info("got uploadrequest, type: " + uploadType); String response = "success"; String callbackName = ""; try { // Create a factory for disk-based file items FileItemFactory factory = new DiskFileItemFactory(); // Create a new file upload handler ServletFileUpload upload = new ServletFileUpload(factory); upload.setSizeMax(1024 * 1024); upload.setFileSizeMax(1024 * 1024 * 500); // Parse the request List<FileItem> /* FileItem */ items = upload.parseRequest(req); Iterator<FileItem> iter = items.iterator(); while (iter.hasNext()) { FileItem item = iter.next(); if (item.isFormField()) { logger.info("formfield " + item.getFieldName()); if ("callbackName".equals(item.getFieldName())) callbackName = item.getString(); } else { logger.info("filefield " + item.getFieldName()); if ("userPicture".equals(uploadType)) { logger.info("Setting new user picture for " + session.getUserProfile()); UserCredentials userCredentials = session.getUserProfile().getUserCredentials(); // creating the small image ByteArrayOutputStream bo = new ByteArrayOutputStream(); scalePictureToMax(new ByteArrayInputStream(item.get()), bo, 50, 50); userCredentials.setSmallPicture(bo.toByteArray()); // creating big picture bo = new ByteArrayOutputStream(); scalePictureToMax(new ByteArrayInputStream(item.get()), bo, 500, 500); userCredentials.setPicture(bo.toByteArray()); session.getUserProfile().setUserCredentials(userCredentials); } } } } catch (Exception e) { logger.error("error sending user picture", e); response = "Error, for details see the server log files."; } logger.info("Callback name: " + callbackName); resp.getWriter() .print( "<script type=\"text/javascript\">window.top." + callbackName + "('" + response + "');</script>"); } } else super.doPost(req, resp); }
protected void doPost(Map<String, Object> model, HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException { // Sends "method not implemented" by default super.doPost(req, resp); }
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { super.doPost(request, response); }
/** * Receives standard HTTP requests from the public <code>service</code> method and dispatches them * to the <code>do</code><i>Method</i> methods defined in this class. This method is an * HTTP-specific version of the {@link javax.servlet.Servlet#service} method. There's no need to * override this method. * * @param req the {@link HttpServletRequest} object that contains the request the client made of * the servlet * @param resp the {@link HttpServletResponse} object that contains the response the servlet * returns to the client * @exception IOException if an input or output error occurs while the servlet is handling the * HTTP request * @exception ServletException if the HTTP request cannot be handled * @see javax.servlet.Servlet#service */ protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String method = req.getMethod(); if (method.equals(METHOD_GET)) { long lastModified = getLastModified(req); if (lastModified == -1) { // servlet doesn't support if-modified-since, no reason // to go through further expensive logic doGet(req, resp); } else { long ifModifiedSince; try { ifModifiedSince = req.getDateHeader(HEADER_IFMODSINCE); } catch (IllegalArgumentException iae) { // Invalid date header - proceed as if none was set ifModifiedSince = -1; } if (ifModifiedSince < (lastModified / 1000 * 1000)) { // If the servlet mod time is later, call doGet() // Round down to the nearest second for a proper compare // A ifModifiedSince of -1 will always be less maybeSetLastModified(resp, lastModified); doGet(req, resp); } else { resp.setStatus(HttpServletResponse.SC_NOT_MODIFIED); } } } else if (method.equals(METHOD_HEAD)) { long lastModified = getLastModified(req); maybeSetLastModified(resp, lastModified); doHead(req, resp); } else if (method.equals(METHOD_POST)) { doPost(req, resp); } else if (method.equals(METHOD_PUT)) { doPut(req, resp); } else if (method.equals(METHOD_DELETE)) { doDelete(req, resp); } else if (method.equals(METHOD_OPTIONS)) { doOptions(req, resp); } else if (method.equals(METHOD_TRACE)) { doTrace(req, resp); } else { // // Note that this means NO servlet supports whatever // method was requested, anywhere on this server. // String errMsg = lStrings.getString("http.method_not_implemented"); Object[] errArgs = new Object[1]; errArgs[0] = method; errMsg = MessageFormat.format(errMsg, errArgs); resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, errMsg); } }