Example usage for javax.servlet.http HttpServletRequest getParameterNames

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

Introduction

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

Prototype

public Enumeration<String> getParameterNames();

Source Link

Document

Returns an Enumeration of String objects containing the names of the parameters contained in this request.

Usage

From source file:com.hihsoft.baseclass.web.controller.BaseController.java

/**
 * request??????/*  w ww  .j  a v  a 2 s  .  c om*/
 * 
 * @param request
 * @param name
 * @return
 * @author Xiaojf
 * @since 2011-5-17
 */
@SuppressWarnings("unchecked")
protected String getParam(HttpServletRequest request, String name) {
    String val = request.getParameter(name);
    if (val != null)
        return val;
    Enumeration<String> names = request.getParameterNames();
    while (names.hasMoreElements()) {
        String n = names.nextElement();
        if (n.equalsIgnoreCase(name)) {
            return request.getParameter(n);
        }
    }
    return null;
}

From source file:com.expressflow.servlets.ExecProcessServlet.java

private void performRequest(HttpServletRequest request, HttpServletResponse response) throws IOException {
    response.setContentType("text/html");

    UserService userService = UserServiceFactory.getUserService();
    User user = userService.getCurrentUser();
    if (user != null) {
        StringBuilder sb = new StringBuilder(request.getRequestURI());
        String processID = sb.substring(6, sb.length());
        if (processID != null) {
            try {
                // TaskQueues do not support UserService functions...
                // Add the process to the flow-processing queue
                TaskOptions taskOptions = TaskOptions.Builder.withUrl("/_ah/queue/flowprocessor");

                Enumeration parameterNames = request.getParameterNames();
                while (parameterNames.hasMoreElements()) {
                    String parameterName = (String) parameterNames.nextElement();
                    String[] paramValues = request.getParameterValues(parameterName);
                    if (paramValues.length == 1) {
                        taskOptions.param(parameterName, paramValues[0]);
                    } else {
                        System.err.print(parameterName + " has more values?!");
                    }/*from   w w w. ja va  2 s . c  o m*/
                }

                //                  Map<String, String[]> parameterMap = request.getParameterMap();
                //                  for (Map.Entry<String, String[]> parameter : parameterMap.entrySet()) {
                //                     for(String value : parameter.getValue()){
                //                        taskOptions.param(parameter.getKey(), value);
                //                     }
                //                  }

                Queue queue = QueueFactory.getQueue("flowprocessor");
                queue.add(taskOptions.param("key", processID));

            } catch (Exception e) {
                log.info(e.getMessage());
            }
        }
    } else {
        response.sendRedirect(response.encodeRedirectURL(userService.createLoginURL(request.getRequestURI())));
    }
}

From source file:com.swiftcorp.portal.generalprofile.web.GeneralprofileDispatchAction.java

public ActionForward addGeneralprofile(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws SystemException, BusinessRuleViolationException, Exception {
    log.info("addGeneralprofile() : Enter");
    HttpSession session = request.getSession();
    DynaValidatorActionForm generalprofileForm = (DynaValidatorActionForm) form;
    GeneralprofileDTO generalprofileDTO = (GeneralprofileDTO) generalprofileForm.get("generalprofile");
    generalprofileDTO = new GeneralprofileDTO();
    DTOObjectReflectionUtil.populateDTOFromRequest(request, generalprofileDTO);

    Enumeration<String> en = request.getParameterNames();

    String key = "";
    String value = "";
    String supplyChainActor = "";
    while (en.hasMoreElements()) {
        key = en.nextElement();//from w  w w  .j  a v  a2 s. c o m
        if (key.startsWith("cb-")) {
            int index = -1;
            value = key.substring(3, key.length());
            supplyChainActor += value;
            log.debug("functionIndex are " + value);

        }
    }
    generalprofileDTO.setSupplyChainActor(supplyChainActor);
    String[][] messageArgValues = { { generalprofileDTO.getUniqueCode() } };
    GeneralprofileSuccessResult result = (GeneralprofileSuccessResult) generalprofileService
            .add(generalprofileDTO);
    WebUtils.setSuccessMessages(request, MessageKeys.ADD_SUCCESS_MESSAGE_KEYS, messageArgValues);
    log.info("addGeneralprofile() : Exit");
    return promptSuccessAddGeneralprofile(mapping, form, request, response);
}

From source file:com.orange.mmp.mvc.ota.Controller.java

/**
 * Display a confirmation page for download
 * @param ticketId The ID of the delivery ticket
 * @param service The current sercice//from  w  ww  .j  ava  2s .c  o  m
 * @param request The incoming HTTP request
 * @return
 */
@SuppressWarnings("unchecked")
private ModelAndView showConfirmationPage(String ticketId, Service service, HttpServletRequest request) {
    ExecutionContext executionContext = ExecutionContext.getInstance();
    executionContext.addInfoMsg("Show confirmation page. Ticket ID = " + ticketId + ", service = "
            + (service != null ? service.getId() : "null"));

    StringBuilder newURL = new StringBuilder(ticketId);
    Enumeration<String> paramEnum = request.getParameterNames();
    boolean paramAdded = false;
    while (paramEnum.hasMoreElements()) {
        String paramNam = paramEnum.nextElement();
        if (!paramNam.equals(Constants.HTTP_PARAMETER_CONFIRM)) {
            newURL.append((paramAdded) ? "&" : "?").append(paramNam).append("=")
                    .append(request.getParameter(paramNam));
            paramAdded = true;
        }
    }

    ModelAndView modelAndView = new ModelAndView(confirmView);
    modelAndView.addObject("noSignOption", service.getSigned());
    modelAndView.addObject("url", newURL.toString());

    return modelAndView;
}

From source file:fr.paris.lutece.plugins.directory.service.upload.DirectoryAsynchronousUploadHandler.java

/**
 * Checks the request parameters to see if an upload submit has been
 * called.//w  w  w.j a  v a  2  s  .  co m
 *
 * @param request the HTTP request
 * @return the name of the upload action, if any. Null otherwise.
 */
public String getUploadAction(HttpServletRequest request) {
    Enumeration<String> enumParamNames = request.getParameterNames();

    while (enumParamNames.hasMoreElements()) {
        String paramName = enumParamNames.nextElement();

        if (paramName.startsWith(UPLOAD_SUBMIT_PREFIX) || paramName.startsWith(UPLOAD_DELETE_PREFIX)) {
            return paramName;
        }
    }

    return null;
}

From source file:com.glaf.core.tag.SystemPageTag.java

public int doEndTag() throws JspException {
     Paging page = null;//from  www  .ja  v a2  s .co  m
     if (name == null) {
         name = "glaf";
     }
     page = (Paging) pageContext.getAttribute(name);
     if (page == null) {
         page = (Paging) pageContext.getRequest().getAttribute(name);
     }
     if (page == null) {
         page = Paging.EMPTY_PAGE;
     }

     if (prefix == null) {
         prefix = "";
     }

     HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();

     String complexQuery = request.getParameter("complexQuery");
     String x_complex_query = request.getParameter("x_complex_query");
     String xyz_complex_query = request.getParameter("xyz_complex_query");
     imagePath = request.getContextPath() + "/images/go.gif";
     Map<String, Object> paramMap = new java.util.HashMap<String, Object>();
     StringBuffer buffer = new StringBuffer();

     Enumeration<?> enumeration = request.getParameterNames();
     while (enumeration.hasMoreElements()) {
         String paramName = (String) enumeration.nextElement();
         String paramValue = request.getParameter(paramName);
         if (paramName.startsWith(prefix)) {
             paramName = paramName.replaceAll(prefix, "");
         }
         if (paramName.startsWith("query_")) {
             if (StringUtils.isNotEmpty(paramValue)) {
                 paramName = paramName.replaceAll("query_", "");
                 paramMap.put(paramName, paramValue);
             }
         }
     }

     Integer count = (Integer) pageContext.getRequest().getAttribute(prefix + PAGE_PART_COUNTER);
     if (count == null) {
         count = 0;
     }
     try {
         JspWriter out = pageContext.getOut();
         page.setPrefix(prefix);
         if (StringUtils.isNotEmpty(form)) {
             String suffix = "_part_" + count.intValue();
             count = count.intValue() + 1;
             if (count.intValue() == 1) {
                 if (paramMap.size() > 0) {
                     String queryString = JsonUtils.encode(paramMap);
                     if (LogUtils.isDebug()) {
                         logger.debug("query string:" + queryString);
                     }
                     queryString = RequestUtils.encodeString(queryString);
                     buffer.append(
                             "\n<input type=\"hidden\" id=\"x_complex_query\" name=\"x_complex_query\" value=\"")
                             .append(queryString).append("\">");
                 }
                 if (StringUtils.isNotEmpty(xyz_complex_query)) {
                     buffer.append(
                             "\n<input type=\"hidden\" id=\"xyz_complex_query\" name=\"xyz_complex_query\" value=\"")
                             .append(xyz_complex_query).append("\">");
                 } else {
                     if (StringUtils.isNotEmpty(x_complex_query)) {
                         buffer.append(
                                 "\n<input type=\"hidden\" id=\"xyz_complex_query\" name=\"xyz_complex_query\" value=\"")
                                 .append(x_complex_query).append("\">");
                     }
                 }
                 if (StringUtils.isNotEmpty(complexQuery)) {
                     buffer.append("\n<input type=\"hidden\" id=\"complexQuery\" name=\"complexQuery\" value=\"")
                             .append(complexQuery).append("\">");
                 }
                 out.println(this.getDefaultHiddenField(page.getCurrentPage()));
                 out.println(buffer.toString());
             }
             pageContext.getRequest().setAttribute(prefix + PAGE_PART_COUNTER, count);
             boolean showCount = true;
             if (StringUtils.equals(display, "0")) {
                 showCount = false;
             }
             String content = this.getPagingScript(page, form, suffix, showCount);
             out.println(content);
         }

     } catch (Exception ex) {
         ex.printStackTrace();
         logger.error(ex);
     }
     return EVAL_PAGE;
 }

From source file:com.o4s.sarGrapher.graph.java

/**
 * Handles the HTTP <code>GET</code> method.
 *
 * @param request servlet request/*  ww  w  . j a v  a 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 {

    TimeSeriesCollection dataset = new TimeSeriesCollection();

    String title = "";
    String ytitle = "";
    int width = 400;
    int height = 300;
    String graphType = "LINE";
    Boolean useSSH = false;
    HttpSession session = request.getSession();
    if (session != null && session.getAttribute("jsch") != null) {
        useSSH = true;
    }

    for (Enumeration e = request.getParameterNames(); e.hasMoreElements();) {
        String name = e.nextElement().toString();
        String val = request.getParameter(name);
        if (val == null)
            continue; // seems unnecessary but for code clarity
        else if (name.equals("title"))
            title = val;
        else if (name.equals("ytitle"))
            ytitle = val;
        else if (name.equals("width"))
            width = Integer.parseInt(val);
        else if (name.equals("height"))
            height = Integer.parseInt(val);
        else if (name.equals("useSSH"))
            useSSH = true;
        else if (name.equals("type"))
            graphType = val;
        else {
            String[] fflds = val.split(":");
            String fn = fflds[0];
            String[] flds = fflds[1].split(",");

            if (fn == null) {
                Logger.getLogger(graph.class.getName()).log(Level.SEVERE,
                        "Unable to find filename from: {0}={1}", new Object[] { name, val });
                return;
            }

            CSV c = null;
            if (useSSH) {
                CSVs cs = new CSVs();
                c = cs.get(fn);
            }
            if (c == null) {
                Logger.getLogger(graph.class.getName()).log(Level.SEVERE, "Unable to find CSV: {0}", fn);
                return;
            }

            ArrayList ds = new ArrayList();

            for (int i = 0; i < flds.length; i++)
                ds.add(new TimeSeries(name + "." + flds[i]));

            try {
                c.open();
                do {
                    try {
                        if (!c.next())
                            break;
                    } catch (Exception ex) { // Missing field
                        if (ex.getMessage().startsWith("Missing fields"))
                            break;
                        Logger.getLogger(graph.class.getName()).log(Level.SEVERE, null, ex);
                    }

                    String heure = (String) c.get("heure");
                    for (int i = 0; i < flds.length; i++) {
                        Double fv;

                        val = (String) c.get(flds[i]);
                        if (val != null) {
                            fv = Double.parseDouble(val);
                        } else {
                            // try to replace variable
                            String str = flds[i];
                            for (String s : c.getFields()) {
                                str = str.replaceAll(s, c.get(s).toString());
                            }
                            Expression exp = new ExpressionBuilder(str).build();
                            ValidationResult v = exp.validate();
                            String errorMsg = "";
                            if (!v.isValid()) {
                                for (String s : v.getErrors()) {
                                    errorMsg += (errorMsg.isEmpty() ? "" : ",") + s;
                                }
                                if (!errorMsg.isEmpty()) {
                                    Logger.getLogger(graph.class.getName()).log(Level.SEVERE,
                                            "Syntax ERROR or missing variables: {0}", errorMsg);
                                }
                            }
                            fv = exp.evaluate();

                        }
                        //dataset.addValue(fv,flds[i],heure);
                        Date dt = new SimpleDateFormat("HH:mm:ss").parse(heure);
                        ((TimeSeries) ds.get(i)).addOrUpdate(new Minute(dt), fv);
                    }
                } while (true);
            } catch (Exception ex) {
                Logger.getLogger(graph.class.getName()).log(Level.SEVERE, null, ex);
            }

            for (int i = 0; i < flds.length; i++)
                dataset.addSeries((TimeSeries) ds.get(i));

        }
    }
    //JFreeChart barChart = ChartFactory.createBarChart(title, "", "Unit vendue", dataset, PlotOrientation.VERTICAL, true, true, false); 
    //JFreeChart barChart = ChartFactory.createTimeSeriesChart(title, title, dataDir, dataset);// .createStackedBarChart(title, "", "", dataset); 
    //        JFreeChart timechart = ChartFactory.createTimeSeriesChart(  
    //            title, // Title  
    //            "Heure",         // X-axis Label  
    //            "",       // Y-axis Label  
    //            dataset,        // Dataset  
    //            true,          // Show legend  
    //            true,          // Use tooltips  
    //            false          // Generate URLs  
    //        );  
    //        Plot p=timechart.getPlot();

    XYItemRenderer r;

    if (graphType.equals("AREA")) {
        r = new XYAreaRenderer();
    } else if (graphType.equals("BAR")) {
        r = new XYBarRenderer();
    } else if (graphType.equals("STACK")) {
        r = new StackedXYAreaRenderer();
    } else {
        r = new StandardXYItemRenderer();
    }

    final DateAxis domainAxis = new DateAxis("Heure");
    domainAxis.setVerticalTickLabels(false);
    domainAxis.setDateFormatOverride(new SimpleDateFormat("HH:mm"));
    domainAxis.setLowerMargin(0.01);
    domainAxis.setUpperMargin(0.01);
    final ValueAxis rangeAxis = new NumberAxis(ytitle);
    final XYPlot plot = new XYPlot(dataset, domainAxis, rangeAxis, r);
    final JFreeChart chart = new JFreeChart(title, plot);

    //        JFreeChart timechart=null;
    //        if( graphType.equals("AREA") ){
    //            timechart = ChartFactory.createXYAreaChart(title, "Heure", "", dataset, PlotOrientation.VERTICAL, true, true, false); 
    //        } else if( graphType.equals("BAR") ){
    //            timechart = ChartFactory.createXYBarChart(title, "Heure", true, "", dataset, PlotOrientation.VERTICAL, true, true, false); 
    //        } else {
    //            timechart = ChartFactory.createXYLineChart(title, "Heure", "", dataset, PlotOrientation.VERTICAL, true, true, false); 
    //        }

    response.setContentType("image/png");
    OutputStream out = response.getOutputStream();
    ChartUtilities.writeChartAsPNG(out, chart, width, height);

}

From source file:org.jasig.cas.support.pac4j.web.flow.ClientBackChannelAction.java

private void log(HttpServletRequest request) {

    logger.debug("=========================================================");
    logger.debug("ClientBackChannelAction.doExecute: ");
    logger.debug("request.method: " + request.getMethod());
    logger.debug("request.requestURI: " + request.getRequestURI());
    logger.debug("request.queryString: " + request.getQueryString());
    logger.debug("request. host port remoteaddress: " + request.getRemoteHost() + " " + request.getRemotePort()
            + " " + request.getRemoteAddr());
    logger.debug("request. parameter:");
    Enumeration enParams = request.getParameterNames();
    while (enParams.hasMoreElements()) {
        String paramName = (String) enParams.nextElement();
        logger.debug(paramName + ": " + request.getParameter(paramName));
    }//w  ww.j a  v  a2 s  . c o  m

    logger.debug("request. attribute:");
    Enumeration enParams2 = request.getAttributeNames();
    while (enParams2.hasMoreElements()) {
        String paramName2 = (String) enParams2.nextElement();
        logger.debug(paramName2 + ": " + request.getAttribute(paramName2));
    }
    logger.debug("=========================================================");
}

From source file:it.eng.spago.dispatching.httpchannel.AdapterHTTP.java

/**
 * Handle simple form.//from w ww  .j  a  va2 s .  c  o  m
 * 
 * @param request the request
 * @param requestContext the request context
 * 
 * @throws SourceBeanException the source bean exception
 */
private void handleSimpleForm(HttpServletRequest request, RequestContextIFace requestContext)
        throws SourceBeanException {
    SourceBean serviceRequest = requestContext.getServiceRequest();
    Enumeration names = request.getParameterNames();
    while (names.hasMoreElements()) {
        String parameterName = (String) names.nextElement();

        if (parameterName.startsWith("QUERY_STRING")) {
            handleQueryStringField(request, serviceRequest, parameterName);
        } else {
            String[] parameterValues = request.getParameterValues(parameterName);
            if (parameterValues != null)
                for (int i = 0; i < parameterValues.length; i++)
                    serviceRequest.setAttribute(parameterName, parameterValues[i]);
        }
    } // while (names.hasMoreElements())
}