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:edu.cornell.mannlib.vedit.controller.BaseEditController.java

protected void populateBeanFromParams(Object bean, HttpServletRequest request) {
    Map params = request.getParameterMap();
    Enumeration paramNames = request.getParameterNames();
    while (paramNames.hasMoreElements()) {
        String key = "";
        try {/*from   w ww  .  ja va 2s  .  c o m*/
            key = (String) paramNames.nextElement();
        } catch (ClassCastException cce) {
            log.error("populateBeanFromParams() could not cast parameter name to String");
        }
        String value = "";
        if (key.equals(MULTIPLEXED_PARAMETER_NAME)) {
            String multiplexedStr = request.getParameterValues(key)[0];
            Map paramMap = FormUtils.beanParamMapFromString(multiplexedStr);
            Iterator paramIt = paramMap.keySet().iterator();
            while (paramIt.hasNext()) {
                String param = (String) paramIt.next();
                String demultiplexedValue = (String) paramMap.get(param);
                FormUtils.beanSet(bean, param, demultiplexedValue);
            }

        } else {
            try {
                value = (String) request.getParameterValues(key)[0];
            } catch (ClassCastException cce) {
                try {
                    value = ((Integer) params.get(key)).toString();
                } catch (ClassCastException ccf) {
                    log.error("populateBeanFromParams() could not cast parameter name to String");
                }
            }
            FormUtils.beanSet(bean, key, value);
        }
    }
}

From source file:gov.nih.nci.cabig.caaers.web.search.AdvancedSearchController.java

@Override
@SuppressWarnings("unchecked")
protected boolean isFormSubmission(HttpServletRequest request) {
    Set<String> paramNames = request.getParameterMap().keySet();
    boolean fromSearchListPage = false;

    fromSearchListPage = paramNames.contains("runSavedQuery");
    String action = (String) findInRequest(request, "_action");
    if (fromSearchListPage)
        return true;
    else if (action != null && (action.equals("flatView")))
        return true;
    else/*from   w  ww.  j ava 2s. c o  m*/
        return super.isFormSubmission(request);
}

From source file:mx.gob.cfe.documentos.web.SobreController.java

@SuppressWarnings("unchecked")
@RequestMapping(value = "/feligreses", params = "term", produces = "application/json")
public @ResponseBody List<LabelValueBean> feligreses(HttpServletRequest request,
        @RequestParam("term") String filtro) {
    for (String nombre : request.getParameterMap().keySet()) {
        log.debug("Param: {} : {}", nombre, request.getParameterMap().get(nombre));
    }/*from  w ww . j a  va  2  s .  c  o m*/

    List<Feligres> feligresia = fDao.lista();
    List<LabelValueBean> valores = new ArrayList<>();
    for (Feligres feligres : feligresia) {
        StringBuilder sb = new StringBuilder();
        sb.append(feligres.getNombre() + " ");
        sb.append(feligres.getApellidoPat() + " ");
        sb.append(feligres.getApellidoMat());
        valores.add(new LabelValueBean(feligres.getId(), sb.toString(), feligres.getNombre()));
    }
    return valores;
}

From source file:com.janrain.servlet.JsonpCallbackFilter.java

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
        throws IOException, ServletException {

    HttpServletRequest httpRequest = (HttpServletRequest) request;
    HttpServletResponse httpResponse = (HttpServletResponse) response;

    Map<String, String[]> parameters = httpRequest.getParameterMap();
    String callbackName = "";
    String[] values = parameters.get("callback");
    if (values != null) {
        callbackName = values[0];//ww w .ja  v a2 s  .  c  om
    }

    if (StringUtils.isNotBlank(callbackName)) {
        // wrap the json in the callback
        OutputStream stream = httpResponse.getOutputStream();
        GenericResponseWrapper wrapper = new GenericResponseWrapper(httpResponse);

        chain.doFilter(request, wrapper);

        stream.write((callbackName + "(").getBytes());
        stream.write(wrapper.getData());
        stream.write(");".getBytes());

        wrapper.setContentType("text/javascript;charset=UTF-8");
        // always return 200 when using the callback to allow the message to
        // reach the browser based function
        wrapper.setStatus(HttpServletResponse.SC_OK);
        stream.close();

    } else {
        // pass the request/response on
        chain.doFilter(request, response);
    }

}

From source file:org.broadleafcommerce.vendor.authorizenet.web.controller.BroadleafAuthorizeNetController.java

protected String requestParamToString(HttpServletRequest request) {
    StringBuffer requestMap = new StringBuffer();
    for (String key : (Set<String>) request.getParameterMap().keySet()) {
        requestMap.append(key + ": " + request.getParameter(key) + ", ");
    }/*ww w. j  a  v  a2s .com*/
    return requestMap.toString();
}

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

public String getPaginationURL(HttpServletRequest request, int page, int elements) {
    String queryParams = "";
    for (Entry<String, String[]> e : request.getParameterMap().entrySet()) {
        if (!e.getKey().equals(URLUtil.PAGINATION_PAGE_PARAM)
                && !e.getKey().equals(URLUtil.PAGINATION_ELEMENTS_PARAM)) {
            queryParams = addKey(queryParams, e.getKey(), e.getValue()[0]);
        }//from   www . j a va  2  s. c  o m
    }
    queryParams = addKey(queryParams, URLUtil.PAGINATION_PAGE_PARAM, "" + page);
    queryParams = addKey(queryParams, URLUtil.PAGINATION_ELEMENTS_PARAM, "" + elements);
    return request.getRequestURL() + URL_PARAMS_DIVIDER + queryParams;
}

From source file:org.opentestsystem.authoring.testauth.rest.PublishingRecordController.java

@RequestMapping(value = "/publishingRecord", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@Secured({ "ROLE_Test Read" })
@PostAuthorize("hasPermission(returnObject, 'ROLE_Test Read')")
@ResponseBody// ww  w .  j a  v a2 s .  co  m
public SearchResponse<PublishingRecord> searchPublishingRecord(final HttpServletRequest request,
        final HttpServletResponse response) {
    return this.publishingRecordService.searchPublishingRecords(request.getParameterMap());
}

From source file:net.groupbuy.plugin.tenpayPartner.TenpayPartnerPlugin.java

@SuppressWarnings("unchecked")
@Override/*from w ww  .j a  v  a2  s  .c o m*/
public boolean verifyNotify(String sn, NotifyMethod notifyMethod, HttpServletRequest request) {
    PluginConfig pluginConfig = getPluginConfig();
    if (generateSign(request.getParameterMap()).equals(request.getParameter("sign"))
            && pluginConfig.getAttribute("partner").equals(request.getParameter("partner"))
            && sn.equals(request.getParameter("out_trade_no"))
            && "0".equals(request.getParameter("trade_state"))) {
        try {
            Map<String, Object> parameterMap = new HashMap<String, Object>();
            parameterMap.put("input_charset", "utf-8");
            parameterMap.put("sign_type", "MD5");
            parameterMap.put("partner", pluginConfig.getAttribute("partner"));
            parameterMap.put("notify_id", request.getParameter("notify_id"));
            String verifyUrl = "https://gw.tenpay.com/gateway/simpleverifynotifyid.xml?input_charset=utf-8&sign_type=MD5&partner="
                    + pluginConfig.getAttribute("partner") + "&notify_id=" + request.getParameter("notify_id")
                    + "&sign=" + generateSign(parameterMap);
            Document document = new SAXReader().read(new URL(verifyUrl));
            Node node = document.selectSingleNode("/root/retcode");
            if ("0".equals(node.getText().trim())) {
                return true;
            }
        } catch (DocumentException e) {
            e.printStackTrace();
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
    }
    return false;
}

From source file:lti.oauth.OAuthFilter.java

@Override
protected void doFilterInternal(HttpServletRequest req, HttpServletResponse res, FilterChain fc)
        throws ServletException, IOException {

    LaunchRequest launchRequest = new LaunchRequest(req.getParameterMap());
    SortedMap<String, String> alphaSortedMap = launchRequest.toSortedMap();
    String signature = alphaSortedMap.remove(OAuthUtil.SIGNATURE_PARAM);

    String calculatedSignature = null;
    try {//from w  w w.java 2  s  .com
        calculatedSignature = new OAuthMessageSigner().sign(secret,
                OAuthUtil.mapToJava(alphaSortedMap.get(OAuthUtil.SIGNATURE_METHOD_PARAM)), "POST",
                req.getRequestURL().toString(), alphaSortedMap);
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        res.sendError(HttpStatus.INTERNAL_SERVER_ERROR.value());
        return;
    }

    if (!signature.equals(calculatedSignature)) {
        // try again with http
        String recalculatedSignature = null;

        if (StringUtils.startsWithIgnoreCase(req.getRequestURL().toString(), "https:")) {
            String url = StringUtils.replaceOnce(req.getRequestURL().toString(), "https:", "http:");
            try {
                recalculatedSignature = new OAuthMessageSigner().sign(secret,
                        OAuthUtil.mapToJava(alphaSortedMap.get(OAuthUtil.SIGNATURE_METHOD_PARAM)), "POST", url,
                        alphaSortedMap);
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                res.sendError(HttpStatus.INTERNAL_SERVER_ERROR.value());
                return;
            }
        }

        if (!signature.equals(recalculatedSignature)) {
            res.sendError(HttpStatus.UNAUTHORIZED.value());
            return;
        }
    }

    fc.doFilter(req, res);
}

From source file:servlets.Tickets.java

/**
 * Handles the HTTP <code>GET</code> method.
 *
 * @param request servlet request//from   w ww.j a  va 2 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 doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("application/json");
    Map<String, String[]> paramMap = request.getParameterMap();

    if (paramMap.isEmpty()) {
        try (PrintWriter out = response.getWriter()) {
            SelectTicketListTemplate ticketList = new SelectTicketListTemplate(response.getStatus(),
                    DataHelper.getInstance().getTicketIds());
            ObjectMapper mapper = new ObjectMapper();
            mapper.writeValue(out, ticketList);
        } catch (Exception e) {

        }
        //?   ID  ? Issue
    }
}