Example usage for javax.servlet.http HttpServletRequest getParameterValues

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

Introduction

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

Prototype

public String[] getParameterValues(String name);

Source Link

Document

Returns an array of String objects containing all of the values the given request parameter has, or null if the parameter does not exist.

Usage

From source file:org.openmrs.module.restrictbyrole.web.controller.RestrictionListController.java

@RequestMapping(method = RequestMethod.POST)
protected String processSubmit(HttpServletRequest request) {
    String[] toDelete = request.getParameterValues("deleteId");
    RestrictByRoleService service = (RestrictByRoleService) Context.getService(RestrictByRoleService.class);
    for (String s : toDelete) {
        Integer id = Integer.valueOf(s);
        service.deleteRoleRestriction(service.getRoleRestriction(id));
    }//from ww  w .j  av a  2 s. c o m
    return "redirect:restrictionList.form";
}

From source file:org.openmrs.module.encounteralerts.web.controller.EncounterAlertsListController.java

@RequestMapping(method = RequestMethod.POST)
protected String processSubmit(HttpServletRequest request) {
    String[] toDelete = request.getParameterValues("deleteId");
    if (toDelete == null) {
        return null;
    }/*from   w  w  w .jav a2s  .  c o m*/
    EncounterAlertsService service = (EncounterAlertsService) Context.getService(EncounterAlertsService.class);
    for (String s : toDelete) {
        Integer id = Integer.valueOf(s);
        service.deleteEncounterAlert(service.getEncounterAlert(id));
    }
    return "redirect:encounterAlertList.form";
}

From source file:org.openmrs.module.restrictbyuser.web.controller.UserRestrictionListController.java

@RequestMapping(method = RequestMethod.POST)
protected String processSubmit(HttpServletRequest request) {
    String[] toDelete = request.getParameterValues("deleteId");
    if (toDelete == null) {
        return null;
    }//w w w . j ava  2s .  c om
    RestrictByUserService service = (RestrictByUserService) Context.getService(RestrictByUserService.class);
    for (String s : toDelete) {
        Integer id = Integer.valueOf(s);
        service.deleteUserRestriction(service.getUserRestriction(id));
    }
    return "redirect:restrictionList.form";
}

From source file:edu.lafayette.metadb.web.metadata.UpdateAdminDescMetadata.java

public static JSONObject whitelist(String id_string, String projname, String type, int itemNumber,
        HttpServletRequest request) throws JSONException {

    JSONObject result = new JSONObject();

    int id = Integer.parseInt(id_string);

    AdminDescItem item = AdminDescItemsDAO.getItem(projname, type, id, itemNumber);
    boolean validated = true;
    String newData = request.getParameter(id_string);

    String error_message = "Cannot update metadata";

    if (newData != null) {
        if (item.isReadableDate()) {
            validated &= isValidDisplayDate(newData);
            error_message = "Display date is not valid";
        } else if (item.isSearchableDate()) {
            validated &= isValidSearchDate(newData);
            error_message = "Search date is not valid";
        } else if (item.isControlled()) {
            newData = "";
            String[] new_terms = request.getParameterValues(id_string);
            if (item.isAdditions()) {
                addTerm(item, new_terms);
            }/* www . j a  v a 2 s . c  om*/

            /**
             * Important: controlled vocab terms are sorted before updating the database
             * To disable sorting, use another data structure since Set does not preserve order,
             * only maintains uniqueness of elements.
             */
            Set<String> vocabList = ControlledVocabDAO.getControlledVocab(item.getVocab());
            Collection<String> updatedVocab;
            if (item.isSorted()) //if sorted, use TreeSet
                updatedVocab = new TreeSet<String>();
            else //otherwise, use LinkedList
                updatedVocab = new LinkedList<String>();
            for (int i = 0; i < new_terms.length; i++) {
                String term = StringUtils.strip(new_terms[i]);
                //MetaDbHelper.note(term);
                if (!term.equals("") && !vocabList.add(term))
                    updatedVocab.add(term);
            }
            int i = 0;

            Iterator<String> itr = updatedVocab.iterator();
            while (itr.hasNext()) {
                newData += itr.next();
                if (i != updatedVocab.size() - 1)
                    newData += ";";
                i++;
            }
        }
        if (validated) {
            result.put("success", true);
            result.put("data", newData);

        } else {
            result.put("success", false);
            result.put("id", id);
            result.put("element", item.getElement());
            result.put("label", item.getLabel());
            result.put("message", error_message);
        }
    }
    return result;
}

From source file:com.yahoo.dba.perf.myperf.springmvc.TermController.java

@Override
protected ModelAndView handleRequestImpl(HttpServletRequest req, HttpServletResponse resp) throws Exception {

    String[] names = req.getParameterValues("name");
    ModelAndView mv = new ModelAndView(jsonView);
    String res = "";
    for (String name : names) {
        if (name == null || name.isEmpty())
            continue;
        if (!name.startsWith("plan.")) {
            String desc = this.frameworkContext.getStatDefManager().getStatDescription(name);
            if (desc == null)
                desc = "no description found.";
            if (name != null && name.startsWith("mysql_status"))
                name = name.substring(13);
            if (res.length() > 0)
                res += "<br />";
            res += "<b>" + name + "</b>: " + desc;
        } else {//  ww w. j  a  v  a2s .  c  o  m
            String[] names2 = name.split(";");
            for (String name2 : names2) {
                if (name2 == null || "plan.extra.".equals(name2) || "plan.select_type.".equals(name2)
                        || "plan.join_type.".equals(name2))
                    continue;
                name2 = name2.trim();
                if (name.startsWith("plan.extra.") && !name2.startsWith("plan.extra."))
                    name2 = "plan.extra." + name2;
                if (name2.indexOf('(') >= 0)
                    name2 = name2.substring(0, name2.indexOf('('));
                else if (name2.startsWith("plan.extra.Cost"))
                    name2 = "plan.extra.Cost";
                String desc = this.frameworkContext.getStatDefManager().getStatDescription(name2);
                if (desc == null)
                    desc = "no description found.";
                if (res.length() > 0)
                    res += "<br />";
                res += "<b>" + name2.substring(5) + "</b>: " + desc;

            }
        }
    }

    mv.addObject("json_result", ResultListUtil.toJSONString(null, null, 0, res));
    return mv;
}

From source file:com.github.matthesrieke.jprox.JProxViaParameterServlet.java

private String resolveTargetUrl(HttpServletRequest req) {
    String[] values = req.getParameterValues(this.parameterKey);
    if (values != null && values.length > 0) {
        try {//from   w ww  . ja v a 2s  . c  o m
            return URLDecoder.decode(values[0], "UTF-8");
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
    }
    throw new RuntimeException(this.parameterKey + " request key not specified!");
}

From source file:ca.watier.echechess.server.UiSessionHandlerInterceptor.java

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
    boolean isAllowed = false;

    String[] uiUuids = request.getParameterValues("uiUuid");

    if (ArrayUtils.isNotEmpty(uiUuids)) { //Authorize only those with an active ui session
        String uiUuid = uiUuids[0];
        isAllowed = uiSessionService.isUiSessionActive(UUID.fromString(uiUuid));

        if (!isAllowed) {
            webSocketService.fireUiEvent(uiUuid, ChessEventMessage.UI_SESSION_EXPIRED,
                    THE_CLIENT_LOST_THE_CONNECTION);
        }//  w  w  w. j  a v a 2  s. c  om
    }

    return isAllowed;
}

From source file:cn.vlabs.umt.ui.actions.ManageRoleAction.java

public ActionForward remove(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) {//ww w . j  a va  2s .  c  o m
    RoleService rs = getRoleService();
    String[] usernames = request.getParameterValues("usernames");
    rs.removeMemeber("admin", usernames);
    return load(mapping, form, request, response);
}

From source file:com.me.controller.AddToDb.java

@Override
protected ModelAndView handleRequestInternal(HttpServletRequest hsr, HttpServletResponse hsr1)
        throws Exception {

    ModelAndView mv = new ModelAndView();

    String[] isbnVal = (String[]) hsr.getParameterValues("isbn");
    String[] titleVal = (String[]) hsr.getParameterValues("bookTitle");
    String[] authorVal = (String[]) hsr.getParameterValues("author");
    String[] priceVal = (String[]) hsr.getParameterValues("price");

    addBooksDAO.addBook(isbnVal, titleVal, authorVal, priceVal);

    mv.setViewName("Success");
    return mv;//ww  w.jav  a 2  s . c  om
}

From source file:org.osmsurround.ae.amenity.AmenityEditorController.java

private Map<String, String> loadDataFromRequest(HttpServletRequest req) {
    Map<String, String> data = new HashMap<String, String>();

    String[] keys = req.getParameterValues("key");
    String[] values = req.getParameterValues("value");

    if (keys == null || values == null || keys.length != values.length) {
        throw new RuntimeException("Bad Request");
    } else {/*  w w  w  .j  a  va  2s . c  o m*/
        for (int x = 0; x < keys.length; x++) {
            String k = keys[x];
            String v = values[x];

            if (v != null && !v.isEmpty())
                data.put(k.trim(), v.trim());
        }
    }
    return data;
}