Example usage for javax.servlet.http HttpServletRequest getParameter

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

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletRequest 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:com.nominanuda.springmvc.QueryParamLocaleResolver.java

public Locale resolveLocale(HttpServletRequest request) {
    String lang = request.getParameter(paramName);
    if (lang != null) {
        Locale locale = StringUtils.parseLocaleString(lang);
        return locale;
    }/*from   w  w w  .  ja va  2s .  co  m*/
    return getDefaultLocale();
}

From source file:com.netflix.zuul.scriptManager.FilterScriptManagerServlet.java

/**
 * Determine if the incoming action + method is a correct combination. If not, output the usage docs and set an error code on the response.
 *
 * @param request/* ww w . j a va2 s  . com*/
 * @param response
 * @return true if valid, false if not
 */
private static boolean isValidAction(HttpServletRequest request, HttpServletResponse response) {
    String action = request.getParameter("action");
    if (action != null) {
        action = action.trim().toUpperCase();
        /* test for GET actions */
        if (VALID_GET_ACTIONS.contains(action)) {
            if (!request.getMethod().equals("GET")) {
                // valid action, wrong method
                setUsageError(405, "ERROR: Invalid HTTP method for action type.", response);
                return false;
            }
            // valid action and method
            return true;
        }

        if (VALID_PUT_ACTIONS.contains(action)) {
            if (!(request.getMethod().equals("PUT") || request.getMethod().equals("POST"))) {
                // valid action, wrong method
                setUsageError(405, "ERROR: Invalid HTTP method for action type.", response);
                return false;
            }
            // valid action and method
            return true;
        }

        // wrong action
        setUsageError(400, "ERROR: Unknown action type.", response);
        return false;
    } else {
        setUsageError(400, "ERROR: Invalid arguments.", response);
        return false;
    }
}

From source file:com.thoughtworks.go.server.web.TokenManager.java

public boolean verify(HttpServletRequest request) {
    String postedToken = request.getParameter(TOKEN);
    String expectedToken = (String) request.getSession().getAttribute(TOKEN);
    return !StringUtils.isBlank(postedToken) && !StringUtils.isBlank(expectedToken)
            && postedToken.equals(expectedToken);
}

From source file:com.glaf.activiti.web.springmvc.ActivitiCallBackController.java

/**
 * /*from ww  w.  j a va  2 s.c o m*/
 * 
 * @param request
 * @return
 */
@ResponseBody
@RequestMapping
public byte[] callback(HttpServletRequest request) {
    String taskId = request.getParameter("taskId");
    return activitiProcessService.callback(taskId);
}

From source file:kwashc.blog.controller.BlogController.java

@RequestMapping(value = "/blog", method = RequestMethod.POST)
public String addComment(HttpServletRequest request) {
    String title = request.getParameter("title");
    String comment = request.getParameter("comment");
    String homepage = request.getParameter("homepage");

    User user = (User) request.getSession(true).getAttribute("USER");
    Database.addComment(new Comment(user, homepage, title, comment));

    return "redirect:/blog"; //redirect to avoid double postings
}

From source file:controller.TwitterController.java

@RequestMapping("enviarTwitter")
public String enviarTwitter(HttpServletRequest req) {
    Twitter twitter = new Twitter(Integer.parseInt(req.getParameter("idpessoa")), req.getParameter("texto"));
    TwitterDao dao = new TwitterDao();
    dao.inserir(twitter);//  w  w  w  .  ja v a 2  s  .  c  o  m
    return "telainicial";
}

From source file:com.glaf.activiti.web.springmvc.ActivitiRollBackController.java

/**
 * /*from ww w. j ava  2s  .co m*/
 * 
 * @param request
 * @return
 */
@ResponseBody
@RequestMapping
public byte[] rollback(HttpServletRequest request) {
    String taskId = request.getParameter("taskId");
    return activitiProcessService.rollback(taskId);
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.vendors.VendorHelper.java

/**
 * Save the request parameters from the Basic Info page
 *//*from  w w w .  j av  a2  s  .c o  m*/
public static void saveBasicInfo(Vendor vendor, HttpServletRequest request) throws EnvoyServletException {
    String buf = (String) request.getParameter("usernameSelect");
    if (buf != null && !buf.equals("")) {
        User user = UserHandlerHelper.getUser(buf);
        vendor.setUser(user);
    }
    buf = (String) request.getParameter("userName");
    if (buf != null && !buf.equals("")) {
        vendor.setUserId(buf);
        String password = (String) request.getParameter("password");
        vendor.setPassword(password);
    }

    buf = (String) request.getParameter("customVendorId");
    if (buf != null && !buf.equals("")) {
        vendor.setCustomVendorId(buf);
    }

    if ("0".equals(request.getParameter("accessAllowed")))
        vendor.useInAmbassador(false);
    else
        vendor.useInAmbassador(true);

    buf = (String) request.getParameter("status");
    if (buf != null)
        vendor.setStatus(buf);
    buf = (String) request.getParameter("firstName");
    if (buf != null)
        vendor.setFirstName(buf);
    buf = (String) request.getParameter("lastName");
    if (buf != null)
        vendor.setLastName(buf);
    buf = (String) request.getParameter("userTitle");
    if (buf != null)
        vendor.setTitle(buf);
    if (request.getParameter("company").equals("false")) {
        vendor.setCompanyName((String) request.getParameter("companies"));
    } else {
        vendor.setCompanyName((String) request.getParameter("companyName"));
    }
    if ("0".equals(request.getParameter("vendorType")))
        vendor.isInternalVendor(false);
    else
        vendor.isInternalVendor(true);
    buf = (String) request.getParameter("notes");
    if (buf != null)
        vendor.setNotes(buf);
    buf = (String) request.getParameter("countries");
    if (buf != null)
        vendor.setNationalities(buf);
    buf = (String) request.getParameter("dateOfBirth");
    if (buf != null)
        vendor.setDateOfBirth(buf);
    buf = (String) request.getParameter("alias");
    if (buf != null)
        vendor.setPseudonym(buf);

}

From source file:org.mobile.mpos.action.manager.ErrorController.java

@ResponseBody
@RequestMapping(value = Mapping.INTERFACE_URL_ERROR)
public Object logout(HttpServletRequest request) {
    String code = request.getParameter("code");
    log.info("?:ERROR-CODE:" + code);
    Map<String, Object> result = new HashMap<String, Object>();
    SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
    result.put("isSuccess", false);
    result.put("respCode", code);
    result.put("respMsg", "?:" + code);
    result.put("respTime", format.format(new Date()));
    log.info("response:" + JSONObject.fromObject(result).toString(4));
    return result;
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.vendors.VendorHelper.java

/**
 * Save the permission data./*from   w w w .j  a  v a  2s . com*/
 */
public static void savePermissions(Vendor vendor, HttpServletRequest request, SessionManager sessionMgr)
        throws EnvoyServletException {
    String toField = (String) request.getParameter("toField");
    ArrayList userPerms = new ArrayList();
    try {
        if (toField != null && !toField.equals("")) {
            String[] perm = toField.split(",");
            for (int i = 0; i < perm.length; i++) {
                userPerms.add(Permission.getPermissionManager().readPermissionGroup(Long.parseLong(perm[i])));
            }
        }
    } catch (Exception e) {
        throw new EnvoyServletException(e);
    }

    sessionMgr.setAttribute("userPerms", userPerms);
}