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.squale.welcom.taglib.table.InternalTableUtil.java

/**
 * @param request la request//w  w w .  j  a v  a  2s  .  co m
 * @return true si on a conserve le pagenumber
 */
public static boolean rememberPageNumber(final ServletRequest request) {
    final String buttons = WelcomConfigurator.getMessage(WelcomConfigurator.TABLES_RELOAD_BUTTONS);
    final String submit = request.getParameter("Submit");
    if ((submit != null) && (buttons.toUpperCase().indexOf(submit.toUpperCase()) >= 0)) {
        return false;
    }
    return true;
}

From source file:com.redhat.rhn.frontend.taglibs.list.RadioColumnTag.java

static String getRadioValue(ServletRequest request, String listName) {
    String value = (String) request.getAttribute(getRadioName(listName));
    if (StringUtils.isBlank(value)) {
        value = request.getParameter(getRadioName(listName));
        if (StringUtils.isBlank(value)) {
            value = request.getParameter(getRadioHidden(listName));
            if (StringUtils.isBlank(value)) {
                value = (String) request.getAttribute(getDefaultValueName(listName));
            }/* ww w .j a v a 2 s .  c  om*/
        }
    }
    request.setAttribute(getRadioName(listName), value);
    return value;
}

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

public static TenantUsage retrieveCurrentTenantUsage(ServletRequest request, ServletConfig config,
        HttpSession session) throws Exception {
    try {//  w w  w  . ja  v  a  2  s  . c  om
        UsageServiceClient serviceClient = new UsageServiceClient(config, session);
        String yearMonth = request.getParameter("year-month");
        if (yearMonth == null) {
            // get the current year month
            yearMonth = getCurrentYearMonth();
        }
        return serviceClient.retrieveCurrentTenantUsage(yearMonth);
    } catch (Exception e) {
        String msg = "Failed to get current tenant usage.";
        log.error(msg, e);
        throw new UIException(msg, e);
    }
}

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

public static TenantUsage[] retrieveTenantUsages(ServletRequest request, ServletConfig config,
        HttpSession session) throws Exception {
    try {//from   w  w w  .j  ava 2s .  co m
        UsageServiceClient serviceClient = new UsageServiceClient(config, session);
        String yearMonth = request.getParameter("year-month");
        if (yearMonth == null) {
            // get the current year month
            yearMonth = getCurrentYearMonth();
        }
        return serviceClient.retrieveTenantUsages(yearMonth);
    } catch (Exception e) {
        String msg = "Failed to get all tenants usages.";
        log.error(msg, e);
        throw new UIException(msg, e);
    }
}

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

public static TenantUsage retrieveTenantUsage(ServletRequest request, ServletConfig config, HttpSession session)
        throws Exception {
    try {/*from  w  w  w.  j av  a 2s  .c om*/
        UsageServiceClient serviceClient = new UsageServiceClient(config, session);
        String yearMonth = request.getParameter("year-month");
        if (yearMonth == null) {
            // get the current year month
            yearMonth = getCurrentYearMonth();
        }
        String tenantIdStr = request.getParameter("tenant-id");
        if (tenantIdStr == null) {
            tenantIdStr = "0";
        }
        return serviceClient.retrieveTenantUsage(yearMonth, Integer.parseInt(tenantIdStr));
    } catch (Exception e) {
        String msg = "Failed to get tenant usages.";
        log.error(msg, e);
        throw new UIException(msg, e);
    }
}

From source file:com.ultrapower.eoms.common.plugin.ecside.filter.ECSideFilter.java

public static String getExportFileName(ServletRequest servletRequest){
   String fileName=servletRequest.getParameter(ECSideConstants.EASY_DATA_EXPORT_FILENAME);
   if (StringUtils.isBlank(fileName)){
      String eda=servletRequest.getParameter(ECSideConstants.EASY_DATA_EXPORT_FLAG);
      if (eda.indexOf('.')>0){
         fileName=eda.substring(eda.indexOf('.')+1);
      }/*from   w ww .  j a  v  a  2  s. c om*/
   }
    return StringUtils.isNotBlank(fileName)?fileName:null;
}

From source file:com.ultrapower.eoms.common.plugin.ecside.filter.ECSideFilter.java

public static String getSqlName(ServletRequest servletRequest){
   String sqlName=servletRequest.getParameter(ECSideConstants.EASY_DATA_ACCESS_SQLNAME);
   if (StringUtils.isBlank(sqlName)){
      String eda=servletRequest.getParameter(ECSideConstants.EASY_DATA_ACCESS_FLAG);
      if (StringUtils.isBlank(eda)){
         eda=servletRequest.getParameter(ECSideConstants.EASY_DATA_EXPORT_FLAG);
      }//from ww w .  j  a  v  a 2s  . c o m
      if (StringUtils.isNotBlank(eda) && eda.indexOf('.')>0){
         sqlName=eda.substring(eda.indexOf('.')+1);
      }
   }
    return StringUtils.isNotBlank(sqlName)?sqlName:null;
}

From source file:dk.netarkivet.harvester.webinterface.DomainDefinition.java

/**
 * Creates a url based on the supplied request where all the parameters are the same, except the
 * <code>ShowUnusedConfigurations</code> boolean, which is flipped.
 *
 * @param request The original 'create domain' request to based the new url on.
 * @return The new url with the <code>ShowUnusedConfigurations</code> boolean switched.
 *//*from   w  w  w . j ava2  s  .c o  m*/
public static String createDomainUrlWithFlippedShowConfigurations(ServletRequest request) {
    boolean showUnusedConfigurationsParam = Boolean
            .parseBoolean(request.getParameter(Constants.SHOW_UNUSED_CONFIGURATIONS_PARAM));
    boolean showUnusedSeedsParam = Boolean
            .parseBoolean(request.getParameter(Constants.SHOW_UNUSED_SEEDS_PARAM));
    StringBuilder urlBuilder = new StringBuilder("/HarvestDefinition/Definitions-edit-domain.jsp?");
    urlBuilder.append(
            Constants.DOMAIN_PARAM + "=" + HTMLUtils.encode(request.getParameter(Constants.DOMAIN_PARAM)));
    urlBuilder.append("&" + Constants.SHOW_UNUSED_CONFIGURATIONS_PARAM + "="
            + Boolean.toString(!showUnusedConfigurationsParam));
    urlBuilder.append("&" + Constants.SHOW_UNUSED_SEEDS_PARAM + "=" + Boolean.toString(showUnusedSeedsParam));
    return urlBuilder.toString();
}

From source file:dk.netarkivet.harvester.webinterface.DomainDefinition.java

/**
 * Creates a url based on the supplied request where all the parameters are the same, except the
 * <code>ShowUnusedSeedLists</code> boolean, which is flipped.
 *
 * @param request The original 'create domain' request to based the new url on.
 * @return The new url with the <code>ShowUnusedSeedLists</code> boolean switched.
 *///w  ww . ja  v a2s .c o m
public static String createDomainUrlWithFlippedShowSeeds(ServletRequest request) {
    boolean showUnusedConfigurationsParam = Boolean
            .parseBoolean(request.getParameter(Constants.SHOW_UNUSED_CONFIGURATIONS_PARAM));
    boolean showUnusedSeedsParam = Boolean
            .parseBoolean(request.getParameter(Constants.SHOW_UNUSED_SEEDS_PARAM));
    StringBuilder urlBuilder = new StringBuilder("/HarvestDefinition/Definitions-edit-domain.jsp?");
    urlBuilder.append(
            Constants.DOMAIN_PARAM + "=" + HTMLUtils.encode(request.getParameter(Constants.DOMAIN_PARAM)));
    urlBuilder.append("&" + Constants.SHOW_UNUSED_CONFIGURATIONS_PARAM + "="
            + Boolean.toString(showUnusedConfigurationsParam));
    urlBuilder.append("&" + Constants.SHOW_UNUSED_SEEDS_PARAM + "=" + Boolean.toString(!showUnusedSeedsParam));
    return urlBuilder.toString();
}

From source file:dk.netarkivet.harvester.webinterface.DomainDefinition.java

/**
 * Extracts all required parameters from the request, checks for any inconsistencies, and passes the requisite data
 * to the updateDomain method for processing.
 * <p>// w  w w.j a  va2 s  . c om
 * For reference, the parameters for this page look something like
 * http://localhost:8076/HarvestDefinition/Definitions-edit-domain.jsp?
 * update=1&name=netarkivet.dk&default=defaultconfig&configName=&order_xml=&
 * load=&maxObjects=&urlListName=&seedList=+&passwordName=&passwordDomain=& passwordRealm=&userName=&password=&
 * crawlertraps=%2Fcgi-bin%2F*%0D%0A%2Ftrap%2F*%0D%0A
 * <p>
 * update: This method throws an exception if update is not set
 * <p>
 * name: must be the name of a known domain
 * <p>
 * comments: optional user-entered comments about the domain
 * <p>
 * default: the defaultconfig is set to this value. Must be non-null and a known configuration of this domain.
 * <p>
 * crawlertraps: a newline-separated list of urls to be ignored. May be empty or null
 * <p>
 * alias: If set, this domain is an alias of the set domain renewAlias: If set, the alias date should be renewed
 *
 * @param context The context of this request
 * @param i18n I18n information
 * @throws IOFailure on updateerrors in the DAO
 * @throws ForwardedToErrorPage if domain is not found, if the edition is out-of-date, or if parameters are missing
 * or invalid
 */
public static void processRequest(PageContext context, I18n i18n) {
    ArgumentNotValid.checkNotNull(context, "PageContext context");
    ArgumentNotValid.checkNotNull(i18n, "I18n i18n");

    HTMLUtils.forwardOnEmptyParameter(context, Constants.DOMAIN_PARAM, Constants.DEFAULT_PARAM);
    ServletRequest request = context.getRequest();
    String name = request.getParameter(Constants.DOMAIN_PARAM).trim();

    if (!DomainDAO.getInstance().exists(name)) {
        HTMLUtils.forwardWithErrorMessage(context, i18n, "errormsg;unknown.domain.0", name);
        throw new ForwardedToErrorPage("Unknown domain '" + name + "'");
    }
    Domain domain = DomainDAO.getInstance().read(name);

    // check the edition number before updating
    long edition = HTMLUtils.parseOptionalLong(context, Constants.EDITION_PARAM, -1L);

    if (domain.getEdition() != edition) {
        HTMLUtils.forwardWithRawErrorMessage(context, i18n, "errormsg;domain.definition.changed.0.retry.1",
                "<br/><a href=\"Definitions-edit-domain.jsp?" + Constants.DOMAIN_PARAM + "="
                        + HTMLUtils.escapeHtmlValues(HTMLUtils.encode(name)) + "\">",
                "</a>");
        throw new ForwardedToErrorPage("Domain '" + name + "' has changed");
    }

    // default configuration
    String defaultConf = request.getParameter(Constants.DEFAULT_PARAM);
    if (!domain.hasConfiguration(defaultConf)) {
        HTMLUtils.forwardWithErrorMessage(context, i18n, "errormsg;unknown.default.configuration.0.for.1",
                defaultConf, name);
        throw new ForwardedToErrorPage("Unknown default configuration '" + defaultConf + "'");
    }

    String crawlertraps = request.getParameter(Constants.CRAWLERTRAPS_PARAM);
    if (crawlertraps == null) {
        crawlertraps = "";
    }
    String comments = request.getParameter(Constants.COMMENTS_PARAM);
    if (comments == null) {
        comments = "";
    }
    String alias = request.getParameter(Constants.ALIAS_PARAM);
    if (alias == null) {
        alias = "";
    }

    String aliasRenew = request.getParameter(Constants.RENEW_ALIAS_PARAM);
    if (aliasRenew == null) {
        aliasRenew = "no";
    }

    boolean renewAlias = aliasRenew.equals("yes");

    ExtendedFieldValueDefinition.processRequest(context, i18n, domain, ExtendedFieldTypes.DOMAIN);

    updateDomain(domain, defaultConf, crawlertraps, comments, alias, renewAlias);
}