Example usage for javax.servlet ServletRequest getParameter

List of usage examples for javax.servlet ServletRequest getParameter

Introduction

In this page you can find the example usage for javax.servlet ServletRequest getParameter.

Prototype

public String getParameter(String name);

Source Link

Document

Returns the value of a request parameter as a String, or null if the parameter does not exist.

Usage

From source file:org.rhq.enterprise.gui.util.WebUtility.java

public static String getOptionalRequestParameter(ServletRequest request, String name, String defaultValue) {
    logWarningIfParameterHasMultipleValues(request, name);
    String value = request.getParameter(name);
    return (value == null) ? defaultValue : value;
}

From source file:io.wcm.sling.commons.request.RequestParam.java

/**
 * Returns a request parameter as integer.
 * @param request Request./*from w ww .  j av  a 2 s. c  o m*/
 * @param param Parameter name.
 * @param defaultValue Default value.
 * @return Parameter value or default value if it does not exist or is not a number.
 */
public static int getInt(ServletRequest request, String param, int defaultValue) {
    String value = request.getParameter(param);
    return NumberUtils.toInt(value, defaultValue);
}

From source file:io.wcm.sling.commons.request.RequestParam.java

/**
 * Returns a request parameter as long./*  w  ww.  j  av  a  2 s. c om*/
 * @param request Request.
 * @param param Parameter name.
 * @param defaultValue Default value.
 * @return Parameter value or default value if it does not exist or is not a number.
 */
public static long getLong(ServletRequest request, String param, long defaultValue) {
    String value = request.getParameter(param);
    return NumberUtils.toLong(value, defaultValue);
}

From source file:org.ecside.filter.ECSideFilter.java

 public static String getExportFileName(ServletRequest servletRequest) {
   String fileName = servletRequest
         .getParameter(ECSideConstants.EASY_DATA_EXPORT_FILENAME);
   if (StringUtils.isBlank(fileName)) {
      fileName = "excel.xls";
   }// w w w.  jav a 2s  .  co  m
   return StringUtils.isNotBlank(fileName) ? fileName : null;
}

From source file:io.wcm.sling.commons.request.RequestParam.java

/**
 * Returns a request parameter as float.
 * @param request Request./* w  ww.j  av a 2s.  c  o  m*/
 * @param param Parameter name.
 * @param defaultValue Default value.
 * @return Parameter value or default value if it does not exist or is not a number.
 */
public static float getFloat(ServletRequest request, String param, float defaultValue) {
    String value = request.getParameter(param);
    return NumberUtils.toFloat(value, defaultValue);
}

From source file:io.wcm.sling.commons.request.RequestParam.java

/**
 * Returns a request parameter as double.
 * @param request Request.//w  w w.j a va2 s  . co m
 * @param param Parameter name.
 * @param defaultValue Default value.
 * @return Parameter value or default value if it does not exist or is not a number.
 */
public static double getDouble(ServletRequest request, String param, double defaultValue) {
    String value = request.getParameter(param);
    return NumberUtils.toDouble(value, defaultValue);
}

From source file:org.apache.stratos.usage.ui.utils.UsageUtil.java

public static PaginatedInstanceUsage retrievePaginatedInstanceUsages(ServletRequest request,
        ServletConfig config, HttpSession session) throws Exception {
    String requestedPage = request.getParameter("requestedPage");
    int pageNumber = 1;
    int numberOfPages = 1;
    int entriesPerPage = 15;
    if (requestedPage != null && requestedPage.length() > 0) {
        pageNumber = new Integer(requestedPage);
    }/*from  w w  w. j  av  a  2 s.c  om*/
    try {
        UsageServiceClient serviceClient = new UsageServiceClient(config, session);
        String yearMonth = request.getParameter("year-month");
        if (yearMonth == null) {
            // get the current year month
            yearMonth = getCurrentYearMonth();
        }
        return serviceClient.retrievePaginatedInstanceUsage(yearMonth, pageNumber, entriesPerPage);
    } catch (Exception e) {
        String msg = "Failed to get paginated instance usages.";
        log.error(msg, e);
        throw new UIException(msg, e);
    }
}

From source file:io.wcm.sling.commons.request.RequestParam.java

/**
 * Returns a request parameter as boolean.
 * @param request Request./*  w w w.  j  a va  2  s .c  om*/
 * @param param Parameter name.
 * @param defaultValue Default value.
 * @return Parameter value or default value if it does not exist or <code>false</code> if it cannot be interpreted as
 *         boolean.
 */
public static boolean getBoolean(ServletRequest request, String param, boolean defaultValue) {
    String value = request.getParameter(param);
    return BooleanUtils.toBoolean(value);
}

From source file:org.apache.stratos.usage.ui.utils.UsageUtil.java

public static PaginatedTenantUsageInfo retrievePaginatedTenantUsages(ServletRequest request,
        ServletConfig config, HttpSession session) throws Exception {
    String requestedPage = request.getParameter("requestedPage");
    int pageNumber = 1;
    int numberOfPages = 1;
    int entriesPerPage = 15;
    if (requestedPage != null && requestedPage.length() > 0) {
        pageNumber = new Integer(requestedPage);
    }//from w  w  w  .  ja v  a 2  s .  c o  m

    try {
        UsageServiceClient serviceClient = new UsageServiceClient(config, session);
        String yearMonth = request.getParameter("year-month");
        if (yearMonth == null) {
            // get the current year month
            yearMonth = getCurrentYearMonth();
        }
        return serviceClient.retrievePaginatedTenantUsages(yearMonth, pageNumber, entriesPerPage);
    } catch (Exception e) {
        String msg = "Failed to get all tenants usages.";
        log.error(msg, e);
        throw new UIException(msg, e);
    }
}

From source file:io.wcm.sling.commons.request.RequestParam.java

/**
 * Returns a request parameter.<br>
 * In addition the method fixes problems with incorrect UTF-8 characters returned by the servlet engine.
 * All character data is converted from ISO-8859-1 to UTF-8 if not '_charset_' parameter is provided.
 * @param request Request.//from  w ww.j av a  2s .co  m
 * @param param Parameter name.
 * @param defaultValue Default value.
 * @return Parameter value or the default value if it is not set.
 */
public static String get(ServletRequest request, String param, String defaultValue) {
    String value = request.getParameter(param);
    if (value != null) {
        // convert encoding to UTF-8 if not form encoding parameter is set
        if (!hasFormEncodingParam(request)) {
            value = convertISO88591toUTF8(value);
        }
        return value;
    } else {
        return defaultValue;
    }
}