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.apache.sentry.api.service.thrift.LogLevelServlet.java

/**
 * Return parameter on servlet request for the given name
 *
 * @param request: Servlet request// w ww  .  j ava2  s  .  co  m
 * @param name: Name of parameter in servlet request
 * @return Parameter in servlet request for the given name, return null if can't find parameter.
 */
private String getParameter(ServletRequest request, String name) {
    String s = request.getParameter(name);
    if (s == null) {
        return null;
    }
    s = s.trim();
    return s.length() == 0 ? null : s;
}

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

/**
 * Returns true if the alpha bar item was selected from the  request
 * @param listName the name of this list, ncessary for unique identification
 * @param req the servlet request.//from  w  w w  . j  a v a2 s. co m
 * @return true if the alpha bar item was selected from the  request
 */
public boolean isSelected(String listName, ServletRequest req) {
    return !StringUtils.isBlank(req.getParameter(makeAlphaKey(listName)));
}

From source file:org.mifosplatform.infrastructure.configuration.service.LicenseUpdateServiceImpl.java

@Transactional
@Override/*w  w  w  .j a  v a  2 s  . co m*/
public void updateLicenseKey(ServletRequest request, MifosPlatformTenant tenant) {

    String licenseKey = request.getParameter("key");
    if (licenseKey == null) {
        throw new LicenseKeyNotFoundException("License key not found");

    }

    boolean isValid = this.checkIfKeyIsValid(licenseKey, tenant);
    if (!isValid) {
        throw new InvalidLicenseKeyException("License key Exipired.");
    }

    this.tenantDetailsService.updateLicenseKey(licenseKey);
    return;
}

From source file:de.qucosa.spring.RoleParameterAuthenticationFilter.java

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
        throws IOException, ServletException {
    String role = request.getParameter("role");
    if (role != null) {
        SecurityContext sctx = SecurityContextHolder.getContext();
        if (sctx.getAuthentication() == null) {
            sctx.setAuthentication(new UsernamePasswordAuthenticationToken(role, role));
        }//from   w w w .  j  av  a  2 s  . c  o m
    }
    chain.doFilter(request, response);
}

From source file:org.sonar.ide.test.RuleServlet.java

@Override
public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
    PrintWriter out = res.getWriter();
    String profile = req.getParameter("profile");
    profile = profile.replace(' ', '_');
    String json = FileUtils// w  ww . j a  v  a2 s  .co m
            .readFileToString(new File(TestServlet.getBaseDir(this) + "/rules/" + profile + ".json"));
    out.println(json);
}

From source file:org.jasig.ssp.security.uportal.KeepSessionAliveFilter.java

protected boolean isIntervalOverridden(ServletRequest request) {
    final String paramVal = StringUtils.trimToNull(request.getParameter(OVERRIDE_INTERVAL_PARAM));
    return paramVal != null && SspStringUtils.booleanFromString(paramVal);
}

From source file:com.rsmart.certification.impl.util.PortalParamManagerImpl.java

public Map<String, String> getParams(ServletRequest request) {
    Map<String, String> map = new HashMap<>();
    for (String key : parameters) {
        String value = request.getParameter(key);
        if (value == null) {
            value = (String) request.getAttribute(key);
        }/*w w  w  .ja v  a 2 s .c om*/

        if (value != null) {
            map.put(key, value);
        }
    }

    return map;
}

From source file:com.iflytek.edu.cloud.frame.spring.DelegatingFilterProxyExt.java

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain)
        throws ServletException, IOException {
    String appkey = request.getParameter("appkey");
    if (excludeAppkeys != null && excludeAppkeys.contains(appkey)) {
        logger.debug("(appkey=" + appkey + ")??oauth?");
        filterChain.doFilter(request, response);
    } else//from ww w . j  a v a  2  s. c o  m
        super.doFilter(request, response, filterChain);
}

From source file:servlets.test_servlets.SynonymsServlet.java

/**
 * Service for the Synonyms servlet/*ww  w  .j ava  2s.  c om*/
 *
 * @param req Required Parameters:
 *            term: The term to find synonyms for
 *            Optional Parameters:
 *            scored: The terms will have scores attached
 *            related: Terms will be minimally related (zeroes will be filtered)
 * @param res Response will contain a list of synonyms or scored synonyms
 * @throws ServletException
 * @throws IOException
 */
@Override
public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {

    String term = StringUtils.trim(req.getParameter("term"));
    Map<String, String[]> params = req.getParameterMap();

    String response;
    if (!params.containsKey("scored")) {
        // If you just want unscored synonyms.
        Set synonyms = SynonymAdapter.getSynonyms(term);
        response = JsonCreator.toJson(synonyms);
    } else {
        // If you want minimally related terms
        if (params.containsKey("related")) {
            List<ScoredTerm> synonyms = SynonymAdapter.getScoredSynonymsWithMinimalRelation(term);
            response = JsonCreator.toJson(synonyms);
        } else {
            // If you want to include everything with the scores
            List<ScoredTerm> synonyms = SynonymAdapter.getScoredSynonymsWithUnrelatedIncluded(term);
            response = JsonCreator.toJson(synonyms);
        }
    }

    ResponseUtils.printResponse(res, response);
}