Example usage for javax.servlet.http HttpServletRequest getParameterMap

List of usage examples for javax.servlet.http HttpServletRequest getParameterMap

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletRequest getParameterMap.

Prototype

public Map<String, String[]> getParameterMap();

Source Link

Document

Returns a java.util.Map of the parameters of this request.

Usage

From source file:classes.Product.java

@Override
protected void doDelete(HttpServletRequest request, HttpServletResponse response) throws IOException {
    Set<String> keySet = request.getParameterMap().keySet();
    try (PrintWriter printer = response.getWriter()) {
        Connection connection = connect();
        if (keySet.contains("productId")) {

            PreparedStatement pStatement;
            String query = "" + "delete FROM products where Product_id=" + request.getParameter("productId");
            pStatement = connection.prepareStatement(query);

            try {
                pStatement.executeUpdate();
            } catch (SQLException ex) {
                System.out.println("SQL Exception " + ex.getMessage());

            }/*from w w  w  . j a  v a 2  s.  c o  m*/
        } else {
            printer.println("No dta found");

        }
    } catch (SQLException ex) {
        System.err.println("SQL Exception Error: " + ex.getMessage());
    }
}

From source file:com.daimler.spm.b2bacceleratoraddon.controllers.pages.AdvanceSearchPageController.java

protected String getPaginationUrlFromHttpRequest(final HttpServletRequest request) {
    final Map<String, String[]> requestParamMap = request.getParameterMap();
    final StringBuilder queryParamBuilder = new StringBuilder();
    final Predicate<Map.Entry<String, String[]>> predicate = entry -> PAGINATION_PARAM_REMOVAL_LOOKUP_TABLE
            .contains(entry.getKey().trim().toUpperCase());
    queryParamBuilder.append("?");
    requestParamMap.entrySet().stream().filter(predicate.negate()).forEach(entry -> queryParamBuilder.append(
            ((queryParamBuilder.length() > 1) ? "&" : "") + entry.getKey() + "=" + entry.getValue()[0]));

    return queryParamBuilder.toString();
}

From source file:com.esri.gpt.control.rest.search.DistributedSearchServlet.java

/**
 * Gets the RIDs specified within the request.
 * //w w w .  j a  v a  2s .co m
 * @param request
 *          the HTTP request
 * @return the RIDs
 */
@SuppressWarnings("unchecked")
private StringSet getRids(HttpServletRequest request) {
    StringSet rids = new StringSet();
    Map<String, String[]> requestParameterMap = request.getParameterMap();
    for (Map.Entry<String, String[]> e : requestParameterMap.entrySet()) {
        if (e.getKey().equalsIgnoreCase("rids")) {
            String[] values = e.getValue();
            if (values != null) {
                for (String tokens : values) {
                    StringTokenizer st = new StringTokenizer(tokens, ",");
                    while (st.hasMoreElements()) {
                        String value = Val.chkStr((String) st.nextElement());
                        if (value.length() > 0) {
                            try {
                                rids.add(URLDecoder.decode(value, "UTF-8"));
                            } catch (UnsupportedEncodingException e1) {
                                // Should never happen
                                LOG.log(Level.WARNING, "Could not decde uuid", e1);
                            }
                        }
                    }
                }
            }
        }
    }

    String arrRids[] = request.getParameterValues("rid");
    for (int i = 0; arrRids != null && i < arrRids.length; i++) {
        rids.add(arrRids[i]);
    }
    return rids;
}

From source file:com.digitalmisfits.support.compat.jasig.cas.web.flow.CasDefaultFlowUrlHandler.java

@Override
public String createFlowExecutionUrl(final String flowId, final String flowExecutionKey,
        final HttpServletRequest request) {
    final StringBuilder builder = new StringBuilder();
    builder.append(request.getRequestURI());
    builder.append("?");
    @SuppressWarnings("unchecked")
    final Map<String, Object> flowParams = new LinkedHashMap<String, Object>(request.getParameterMap());
    flowParams.put(this.flowExecutionKeyParameter, flowExecutionKey);
    appendQueryParameters(builder, flowParams, getEncodingScheme(request));
    return builder.toString();
}

From source file:org.schedoscope.metascope.service.MetascopeURLService.java

public String getExclusiveFilterURL(HttpServletRequest request, String key, String value) {
    value = cleanseValue(value);//from  w w  w  .jav  a2 s  .  co  m
    String queryParams = "";
    boolean doNotAdd = false;
    for (Entry<String, String[]> e : request.getParameterMap().entrySet()) {
        if (e.getKey().equals(URLUtil.PAGINATION_PAGE_PARAM)) {
            queryParams = addKey(queryParams, e.getKey(), "1");
        } else if (!e.getKey().equals(key)) {
            queryParams = addKey(queryParams, e.getKey(), e.getValue()[0]);
        } else {
            if (value.equals(cleanseValue(e.getValue()[0]))) {
                doNotAdd = true;
            }
        }
    }
    if (!doNotAdd) {
        queryParams = addKey(queryParams, key, value);
    }
    return request.getRequestURL() + URL_PARAMS_DIVIDER + queryParams;
}

From source file:com.qcadoo.view.internal.controllers.FileResolverController.java

@RequestMapping(value = "{tenantId:\\d+}/{firstLevel:\\d+}/{secondLevel:\\d+}/{fileName}", method = RequestMethod.GET)
public void resolve(final HttpServletRequest request, final HttpServletResponse response,
        @PathVariable("tenantId") final String tenantId) {
    String path = fileService.getPathFromUrl(request.getRequestURI());

    boolean removeFileAfterProcessing = request.getParameterMap().containsKey("clean");

    if (Integer.valueOf(tenantId) != MultiTenantUtil.getCurrentTenantId()) {
        try {//from w  w w .  j av  a2s . c  o m
            response.sendRedirect("/error.html?code=404");
        } catch (IOException e) {
            throw new IllegalStateException(e.getMessage(), e);
        }
    }

    InputStream input = null;

    try {
        input = fileService.getInputStream(path);

        if (input == null) {
            response.sendRedirect("/error.html?code=404");
        } else {
            OutputStream output = response.getOutputStream();

            int bytes = IOUtils.copy(input, output);

            response.setHeader("Content-disposition", "inline; filename=" + fileService.getName(path));
            response.setContentType(fileService.getContentType(path));
            response.setContentLength(bytes);

            output.flush();
        }
    } catch (IOException e) {
        IOUtils.closeQuietly(input);
        throw new IllegalStateException(e.getMessage(), e);
    }

    if (removeFileAfterProcessing) {
        fileService.remove(path);
    }
}

From source file:eu.europa.ec.eci.oct.webcommons.controller.HttpGetController.java

protected void storeParamsToModel(Model model, HttpServletRequest request) {
    @SuppressWarnings("unchecked")
    Map<String, String[]> params = request.getParameterMap();
    for (Map.Entry<String, String[]> param : params.entrySet()) {
        model.addAttribute(param.getKey(), param.getValue().length > 0 ? param.getValue()[0] : "");
    }//from   ww  w  . j a  va 2  s. com
}

From source file:net.shopxx.plugin.alipayEscowPayment.AlipayEscowPaymentPlugin.java

@Override
public boolean verifyNotify(PaymentPlugin.NotifyMethod notifyMethod, HttpServletRequest request) {
    PluginConfig pluginConfig = getPluginConfig();
    PaymentLog paymentLog = getPaymentLog(request.getParameter("out_trade_no"));
    if (paymentLog != null && generateSign(request.getParameterMap()).equals(request.getParameter("sign"))
            && pluginConfig.getAttribute("partner").equals(request.getParameter("seller_id"))
            && ("WAIT_SELLER_SEND_GOODS".equals(request.getParameter("trade_status"))
                    || "TRADE_FINISHED".equals(request.getParameter("trade_status")))
            && paymentLog.getAmount().compareTo(new BigDecimal(request.getParameter("total_fee"))) == 0) {
        Map<String, Object> parameterMap = new HashMap<String, Object>();
        parameterMap.put("service", "notify_verify");
        parameterMap.put("partner", pluginConfig.getAttribute("partner"));
        parameterMap.put("notify_id", request.getParameter("notify_id"));
        if ("true".equals(WebUtils.post("https://mapi.alipay.com/gateway.do", parameterMap))) {
            return true;
        }/* w ww . j  a  va 2  s  .  co  m*/
    }
    return false;
}

From source file:net.shopxx.plugin.alipayBankPayment.AlipayBankPaymentPlugin.java

@Override
public boolean verifyNotify(PaymentPlugin.NotifyMethod notifyMethod, HttpServletRequest request) {
    PluginConfig pluginConfig = getPluginConfig();
    PaymentLog paymentLog = getPaymentLog(request.getParameter("out_trade_no"));
    if (paymentLog != null && generateSign(request.getParameterMap()).equals(request.getParameter("sign"))
            && pluginConfig.getAttribute("partner").equals(request.getParameter("seller_id"))
            && ("TRADE_SUCCESS".equals(request.getParameter("trade_status"))
                    || "TRADE_FINISHED".equals(request.getParameter("trade_status")))
            && paymentLog.getAmount().compareTo(new BigDecimal(request.getParameter("total_fee"))) == 0) {
        Map<String, Object> parameterMap = new HashMap<String, Object>();
        parameterMap.put("service", "notify_verify");
        parameterMap.put("partner", pluginConfig.getAttribute("partner"));
        parameterMap.put("notify_id", request.getParameter("notify_id"));
        if ("true".equals(WebUtils.post("https://mapi.alipay.com/gateway.do", parameterMap))) {
            return true;
        }/*  ww w  .j  ava 2s  . c  o  m*/
    }
    return false;
}

From source file:net.eusashead.hateoas.hal.response.impl.HalPageResponseBuilderImpl.java

/**
 * Get the existing request //from ww  w.  j ava  2 s.c  o  m
 * parameters and increment
 * the page parameter (or decrement).
 * 
 * The request should be identical except
 * for the page parameter
 * @param request
 * @param modifier
 * @return
 */
private Map<String, String[]> modifyPageNumber(HttpServletRequest request, int modifier) {
    Map<String, String[]> oldParams = request.getParameterMap();
    Map<String, String[]> newParams = new HashMap<String, String[]>();

    // Set all parameters other than page number
    for (String key : oldParams.keySet()) {
        String[] value = oldParams.get(key);
        if (!key.equals(pageParameter)) {
            newParams.put(key, value);
        }
    }

    // Set page number
    int page = this.page.getNumber() + modifier;
    newParams.put(pageParameter, new String[] { Integer.valueOf(page).toString() });

    return newParams;
}