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:net.shopxx.plugin.alipayLogin.AlipayLoginPlugin.java

@Override
public boolean verifyNotify(HttpServletRequest request) {
    PluginConfig pluginConfig = getPluginConfig();
    if (generateSign(request.getParameterMap()).equals(request.getParameter("sign"))
            && "T".equals(request.getParameter("is_success"))) {
        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  w  w .j ava2 s .  c  om*/
    }
    return false;
}

From source file:com.zuoxiaolong.blog.common.web.CommonHandlerExceptionResolver.java

@Override
public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler,
        Exception exception) {//from   w  w w  .j av  a2  s  . c o  m
    Map<String, String[]> parameterMap = request.getParameterMap();
    logException(handler, exception, parameterMap);
    if (exception instanceof AuthorizationException) {
        ModelAndView modelAndView = new ModelAndView("redirect:" + loginPage);
        return modelAndView;
    } else {
        ModelAndView modelAndView = new ModelAndView("redirect:" + errorPage);
        return modelAndView;
    }
}

From source file:br.com.softgraf.model.command.CadastrarFornecedor.java

@Override
public String execute(HttpServletRequest request, HttpServletResponse response) {

    Fornecedor fornecedor = new Fornecedor();

    try {/*from   w ww.  j av a  2s. co  m*/
        BeanUtils.populate(fornecedor, request.getParameterMap());

        System.out.println(fornecedor.toString());

        if (fornecedor.isValid()) {
            DAO<Fornecedor> fornecedorDao = new DAOImpl<Fornecedor>(Fornecedor.class,
                    (Session) request.getAttribute(HibernateUtil.HIBERNATE_SESSION));
            fornecedorDao.salvar(fornecedor);
            request.setAttribute("mensagem", "Fornecedor gravado com sucesso: " + fornecedor.getNome());
        } else {
            System.out.println("falta dados");
            request.setAttribute("mensagem", "Preencha os campos obrigatrios");
        }

    } catch (IllegalAccessException e) {
        request.setAttribute("mensagem", "Problemas com preenchimento do Bean");
        e.printStackTrace();

    } catch (InvocationTargetException e) {
        request.setAttribute("mensagem", "Problemas com preenchimento do Bean");
        e.printStackTrace();
    }

    return "cadastra_fornecedor.jsp";
}

From source file:eu.europa.ejusticeportal.dss.controller.action.GetSealedPdfTest.java

@SuppressWarnings("unchecked")
private void getSealedPdf() throws Exception {
    GetSealedPdf d = new GetSealedPdf();
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    HttpServletRequest request = getRequest();
    request.getParameterMap().put(SigningAction.DATA_PARAM, new String[] { Utils.toString(new Fingerprint()) });
    ServletOutputStream sos = new ServletOutputStreamImpl(baos);
    d.elaborate(portal, request, getResponse(sos));
    String s = new String(baos.toByteArray(), "UTF-8");
    Gson gson = new Gson();
    DataWrapper w = gson.fromJson(s, DataWrapper.class);
    SealedPDF spdf = (SealedPDF) Utils.fromString(w.getData());
    byte[] doc = Base64.decodeBase64(spdf.getPdfBase64());
    OutputStream os = new FileOutputStream("target/hello-world-sealed.pdf");
    IOUtils.write(doc, os);//from   w  w w  . j  a v  a  2s  . c o m
    PDFDocumentValidator validator = (PDFDocumentValidator) SignedDocumentValidator
            .fromDocument(new InMemoryDocument(doc));

    validator.setCertificateVerifier(new CommonCertificateVerifier(null, null, null, null));
    doc = PdfUtils.signPdf(doc, SealedPDFService.getInstance().getToken());
    assertTrue(
            TestUtils.isSealed(null, doc, SealedPDFService.getInstance().getToken(), SealMethod.SEAL_CUSTOM));
    String testXML = new String(PdfUtils.extractAttachment(
            IOUtils.toByteArray(new FileInputStream("target/hello-world-sealed.pdf")),
            SealedPDFService.EMBEDDED_XML_ID), "UTF-8");
    assertEquals(testXML, GetSealedPdfTest.TEST_XML);

}

From source file:edu.cornell.mannlib.vitro.webapp.utils.log.LogUtils.java

private String requestProperties(HttpServletRequest req) {
    @SuppressWarnings("unchecked")
    Map<String, String[]> map = req.getParameterMap();

    String s = req.getRequestURL().append('\n').toString();
    for (String name : new TreeSet<String>(map.keySet())) {
        s += "   " + name + " = " + Arrays.toString(map.get(name)) + '\n';
    }//from  w ww .  ja  v  a2s  .co m
    return s.trim();
}

From source file:net.commerce.zocalo.experiment.config.SessionConfigurationTest.java

public void xtestReadFromRequestParameters() throws TypeMisMatch {
    HttpServletRequest req = new MockHttpServletRequest();
    Map map = req.getParameterMap();
    map.put("duration", "2");
    //        map.put("duration", "2:00");
    map.put("rounds", "3");
    String title = "simpleExperiment";
    map.put("title", title);
    map.put("priceBettering", "true");
    map.put("wholeShareTrading", "false");
    ExperimentConfig config = new ExperimentConfig(req);
    assertEquals("should set duration from request", 120, config.getTime("duration"));
    assertEquals(3, config.getInt("rounds"));
    assertEquals(title, config.getString("title"));
}

From source file:cn.newgxu.lab.core.config.MappingJacksonJsonpView.java

@Override
public void render(Map<String, ?> model, HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    if (request.getMethod().toUpperCase().equals("GET")) {
        if (request.getParameterMap().containsKey("callback")) {
            ServletOutputStream ostream = response.getOutputStream();
            //            try
            ostream.write(new String("try{" + request.getParameter("callback") + "(").getBytes());
            super.render(model, request, response);
            ostream.write(new String(");}catch(e){}").getBytes());
            //            ????closeflushspring?
            //            ?
            ostream.flush();/*from  ww  w .  j  a  v a2  s.  co  m*/
            ostream.close();
        } else {
            super.render(model, request, response);
        }
    } else {
        super.render(model, request, response);
    }
}

From source file:ru.org.linux.spring.boxlets.AbstractBoxlet.java

@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    ModelAndView mav = getData(request);
    if (mav == null) {
        mav = new ModelAndView();
    }/*from   ww w.  ja va2 s.c o  m*/

    if (request.getParameterMap().containsKey("edit")) {
        mav.addObject("editMode", Boolean.TRUE);
    }
    return mav;
}

From source file:com.zuoxiaolong.blog.common.web.JsonHandlerExceptionResolver.java

@Override
public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler,
        Exception exception) {//w  w  w .ja  v  a 2  s  .c om
    Map<String, String[]> parameterMap = request.getParameterMap();
    logException(handler, exception, parameterMap);
    JsonResponse result = new JsonResponse(exception);
    ModelAndView view = new ModelAndView(errorView);
    view.addObject(KEY, result);
    return view;
}

From source file:guru.nidi.raml.doc.servlet.MirrorServlet.java

private void query(HttpServletRequest req, PrintWriter out) {
    out.println("query");
    for (Map.Entry<String, String[]> entry : req.getParameterMap().entrySet()) {
        out.print(entry.getKey() + ": ");
        for (String s : entry.getValue()) {
            out.print("'" + s + "', ");
        }//from w  ww .j  a  va2 s  . c  om
        out.println();
    }
    out.println();
}