List of usage examples for javax.servlet.http HttpServletRequest getParameterMap
public Map<String, String[]> getParameterMap();
From source file:ca.fastenalcompany.servlet.ProductServlet.java
/** * DELETE /products?id={id}/*from w w w .ja va 2 s . c om*/ * * @param request * @param response * @throws ServletException * @throws IOException */ @Override protected void doDelete(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/plain-text"); Set<String> keySet = request.getParameterMap().keySet(); if (keySet.contains("id") && !request.getParameter("id").isEmpty()) { int productid = update(PropertyManager.getProperty("db_delete"), request.getParameter("id")); if (productid > 0) { response.getWriter().write(""); } else { response.setStatus(500); } } }
From source file:co.propack.sample.payment.service.gateway.NullPaymentGatewayHostedWebResponseServiceImpl.java
@Override public PaymentResponseDTO translateWebResponse(HttpServletRequest request) throws PaymentException { PaymentResponseDTO responseDTO = new PaymentResponseDTO(PaymentType.THIRD_PARTY_ACCOUNT, NullPaymentGatewayType.NULL_HOSTED_GATEWAY) .rawResponse(webResponsePrintService.printRequest(request)); Map<String, String[]> paramMap = request.getParameterMap(); Money amount = Money.ZERO;// w w w.j a v a 2 s . com if (paramMap.containsKey(NullPaymentGatewayConstants.TRANSACTION_AMT)) { String amt = paramMap.get(NullPaymentGatewayConstants.TRANSACTION_AMT)[0]; amount = new Money(amt); } responseDTO.successful(true) .completeCheckoutOnCallback(Boolean .parseBoolean(paramMap.get(NullPaymentGatewayConstants.COMPLETE_CHECKOUT_ON_CALLBACK)[0])) .amount(amount).paymentTransactionType(PaymentTransactionType.UNCONFIRMED) .orderId(paramMap.get(NullPaymentGatewayConstants.ORDER_ID)[0]) .responseMap(NullPaymentGatewayConstants.RESULT_MESSAGE, paramMap.get(NullPaymentGatewayConstants.RESULT_MESSAGE)[0]); return responseDTO; }
From source file:org.fusesource.restygwt.server.basic.EchoTestGwtServlet.java
@SuppressWarnings("unchecked") private void doEchoRequest(HttpServletRequest request, HttpServletResponse response) throws IOException { Echo echo = new Echo(); echo.path = request.getPathInfo();/*from www. j av a 2 s . c o m*/ echo.params = new HashMap<String, String>(); ObjectMapper mapper = new ObjectMapper(); for (Map.Entry<String, String[]> entry : (Set<Map.Entry<String, String[]>>) request.getParameterMap() .entrySet()) { if (entry.getValue().length == 1) { echo.params.put(entry.getKey(), entry.getValue()[0]); } else { echo.params.put(entry.getKey(), mapper.writeValueAsString(entry.getValue())); } } response.setContentType("application/json"); mapper.writeValue(response.getOutputStream(), echo); }
From source file:it.marcoberri.mbmeteo.action.chart.GetLastUDial.java
/** * Processes requests for both HTTP/*from w w w. j a v a 2 s . c o m*/ * <code>GET</code> and * <code>POST</code> methods. * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { log.debug("start : " + this.getClass().getName()); final HashMap<String, String> params = getParams(request.getParameterMap()); final Integer dimy = Default.toInteger(params.get("dimy"), 600); final Integer dimx = Default.toInteger(params.get("dimx"), 800); Meteolog meteolog = ds.find(Meteolog.class).order("-time").limit(1).get(); DefaultValueDataset dataset = new DefaultValueDataset(meteolog.getOutdoorHumidity()); // get data for diagrams DialPlot plot = new DialPlot(); plot.setInsets(RectangleInsets.ZERO_INSETS); //plot.setView(0.1, 0.1, 0.9, 0.9); // plot.set plot.setDataset(0, dataset); GradientPaint gp = new GradientPaint(new Point(), new Color(255, 255, 255), new Point(), new Color(170, 170, 220)); DialBackground db = new DialBackground(gp); db.setGradientPaintTransformer( new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_HORIZONTAL)); plot.setBackground(db); StandardDialScale scale = new StandardDialScale(); scale.setLowerBound(0); scale.setUpperBound(100); scale.setTickLabelOffset(0.14); scale.setTickLabelFont(new Font("Dialog", Font.PLAIN, 10)); plot.addScale(0, scale); plot.setInsets(RectangleInsets.ZERO_INSETS); DialPointer needle = new DialPointer.Pointer(0); plot.addLayer(needle); JFreeChart chart1 = new JFreeChart(plot); chart1.setTitle("Humidity %"); final File f = File.createTempFile("mbmeteo", ".jpg"); ChartUtilities.saveChartAsJPEG(f, chart1, dimx, dimy); response.setContentType("image/jpeg"); response.setHeader("Content-Length", "" + f.length()); response.setHeader("Content-Disposition", "inline; filename=\"" + f.getName() + "\""); final OutputStream out = response.getOutputStream(); final FileInputStream in = new FileInputStream(f.toString()); final int size = in.available(); final byte[] content = new byte[size]; in.read(content); out.write(content); in.close(); out.close(); }
From source file:ca.fastenalcompany.servlet.ProductServlet.java
/** * Provides POST /products?name={n}&description={d}&quantity={q} * * @param request servlet request/*from ww w.j a v a2 s . c o m*/ * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/plain-text"); Set<String> keySet = request.getParameterMap().keySet(); if (keySet.contains("name") && keySet.contains("description") && keySet.contains("quantity")) { int productid = update(PropertyManager.getProperty("db_insert"), request.getParameter("name"), request.getParameter("description"), request.getParameter("quantity")); if (productid > 0) { String url = request.getRequestURL().toString() + "/" + productid; response.getWriter().write(url); } else { response.setStatus(500); } } }
From source file:com.ari.controller.catalog.CategoryController.java
private String getLinkUrl(String sort) { HttpServletRequest request = BroadleafRequestContext.getBroadleafRequestContext().getRequest(); String baseUrl = request.getRequestURL().toString(); Map<String, String[]> params = new HashMap<String, String[]>(request.getParameterMap()); if (StringUtils.isNotBlank(sort)) { params.put(ProductSearchCriteria.SORT_STRING, new String[] { sort }); } else {// ww w . j ava 2 s . c om params.remove(ProductSearchCriteria.SORT_STRING); } params.remove(ProductSearchCriteria.PAGE_NUMBER); String url = ProcessorUtils.getUrl(baseUrl, params); return url; }
From source file:ca.fastenalcompany.servlet.ProductServlet.java
/** * PUT /products?id={id}&&name={n}&description={d}&quantity={q} * * @param request/*from w ww . ja va 2 s . c o m*/ * @param response * @throws ServletException * @throws IOException */ @Override protected void doPut(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/plain-text"); Set<String> keySet = request.getParameterMap().keySet(); if (keySet.contains("id") && keySet.contains("name") && keySet.contains("description") && keySet.contains("quantity") && !request.getParameter("id").isEmpty()) { int productid = update(PropertyManager.getProperty("db_update"), request.getParameter("name"), request.getParameter("description"), request.getParameter("quantity"), request.getParameter("id")); if (productid > 0) { String url = request.getRequestURL().toString() + "/" + productid; response.getWriter().write(url); } else { response.setStatus(500); } } }
From source file:de.thorstenberger.taskmodel.view.SavePageAction.java
private void processInteractiveTasklets(final ComplexTasklet ct, final List<SubTasklet> subtasklets, final List<SubmitData> submitDatas, final HttpServletRequest request) { for (int i = 0; i < subtasklets.size(); i++) { final SubTasklet subTasklet = subtasklets.get(i); if (request.getParameterMap().containsKey("doAutoCorrection_" + subTasklet.getVirtualSubtaskNumber())) { // FIXME: add TaskModelSecurityException being subclassed from // SecurityException if (!subTasklet.isInteractiveFeedback()) { throw new SecurityException( "No interactive feedback allowed for SubTaskDef " + subTasklet.getSubTaskDefId()); }//from w ww .j a v a 2s .co m ct.doInteractiveFeedback(subTasklet, submitDatas.get(i)); } } }
From source file:net.anthonychaves.bookmarks.web.OpenIdController.java
@RequestMapping(value = "/return") public String openIdReturn(HttpServletRequest request, HttpSession session) { // extract the parameters from the authentication response // (which comes in as a HTTP request from the OpenID provider) ParameterList openidResp = new ParameterList(request.getParameterMap()); // retrieve the previously stored discovery information DiscoveryInformation discovered = (DiscoveryInformation) session.getAttribute("discovered"); // extract the receiving URL from the HTTP request StringBuffer receivingURL = request.getRequestURL(); String queryString = request.getQueryString(); if (queryString != null && queryString.length() > 0) { receivingURL.append("?").append(request.getQueryString()); }//w w w . jav a 2s. co m // verify the response VerificationResult verification = null; try { verification = manager.verify(receivingURL.toString(), openidResp, discovered); // examine the verification result and extract the verified identifier Identifier verified = verification.getVerifiedId(); if (verified != null) { // success, use the verified identifier to identify the user String[] attributes = inspectOpenIdMessage(verification); User user = userService.findUser(attributes[0]); if (user == null) { user = new User(); user.setEmailAddress(attributes[0]); user.setFirstName(attributes[1]); user.setLastName(attributes[2]); user = userService.createUser(user); } session.setAttribute("user", user); return "redirect:/b/user"; } else { // OpenID authentication failed return "redirect:user_new"; } } catch (Exception e) { throw new RuntimeException(e); } }
From source file:de.ifgi.mosia.wpswfs.handler.GetFeatureHandler.java
@Override protected HttpResponse handleGet(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServiceException { HttpResponse response;/*from w w w . j a v a 2 s . c om*/ try { response = executeGetFeature(req.getParameterMap()); } catch (IOException e) { logger.warn(e.getMessage(), e); throw new IOException("Proxy server issue: " + e.getMessage()); } if (response.getStatusLine().getStatusCode() > HttpStatus.SC_MULTIPLE_CHOICES) { throw new IOException("Proxy server issue. HTTP Status " + response.getStatusLine().getStatusCode()); } else { return postProcessFeatures(response); } }