List of usage examples for javax.servlet.http HttpServletRequest getParameter
public String getParameter(String name);
String
, or null
if the parameter does not exist. From source file:com.lily.dap.web.util.Struts2Utils.java
/** * Gets a parameter as a string./* w ww. j a v a2 s. co m*/ * * @param request * The HttpServletRequest object, known as "request" in a JSP * page. * @param name * The name of the parameter you want to get * @param emptyStringsOK * Return the parameter values even if it is an empty string. * @return The value of the parameter or null if the parameter was not * found. */ public static String getParameter(String name, boolean emptyStringsOK) { HttpServletRequest request = getRequest(); String temp = request.getParameter(name); if (temp != null) { if (temp.equals("") && !emptyStringsOK) { return null; } else { return temp; } } else { return null; } }
From source file:com.lily.dap.web.util.Struts2Utils.java
/** * Gets a parameter as an int./* w w w.ja v a2 s . co m*/ * * @param request * The HttpServletRequest object, known as "request" in a JSP * page. * @param name * The name of the parameter you want to get * @return The int value of the parameter specified or the default value if * the parameter is not found. */ public static int getIntParameter(String name, int defaultNum) { HttpServletRequest request = getRequest(); String temp = request.getParameter(name); if (temp != null && !temp.equals("")) { int num = defaultNum; try { num = Integer.parseInt(temp.trim()); } catch (Exception ignored) { } return num; } else { return defaultNum; } }
From source file:com.lily.dap.web.util.Struts2Utils.java
/** * Gets a parameter as a double./*w ww .j av a 2 s .c o m*/ * * @param request * The HttpServletRequest object, known as "request" in a JSP * page. * @param name * The name of the parameter you want to get * @return The double value of the parameter specified or the default value * if the parameter is not found. */ public static double getDoubleParameter(String name, double defaultNum) { HttpServletRequest request = getRequest(); String temp = request.getParameter(name); if (temp != null && !temp.equals("")) { double num = defaultNum; try { num = Double.parseDouble(temp.trim()); } catch (Exception ignored) { } return num; } else { return defaultNum; } }
From source file:com.lily.dap.web.util.Struts2Utils.java
/** * Gets a parameter as a long.//w w w .j a va 2s .c o m * * @param request * The HttpServletRequest object, known as "request" in a JSP * page. * @param name * The name of the parameter you want to get * @return The long value of the parameter specified or the default value if * the parameter is not found. */ public static long getLongParameter(String name, long defaultNum) { HttpServletRequest request = getRequest(); String temp = request.getParameter(name); if (temp != null && !temp.equals("")) { long num = defaultNum; try { num = Long.parseLong(temp.trim()); } catch (Exception ignored) { } return num; } else { return defaultNum; } }
From source file:com.eurelis.opencms.admin.xmltransformation.ui.CmsXmlMockProcessDialog.java
public static CmsXmlMockProcessDialog newInstance(PageContext context, HttpServletRequest req, HttpServletResponse res) {//from www . j a va2 s . c om String currentParamSessionSortCol = (String) context.getAttribute("sort_column", PageContext.SESSION_SCOPE); CmsListOrderEnum currentSessionSortOrder = (CmsListOrderEnum) context.getAttribute("sort_order", PageContext.SESSION_SCOPE); String requestParamSessionSortCol = req.getParameter(PARAM_SORT_COL); String action = req.getParameter(PARAM_ACTION); CmsListOrderEnum listOrder; boolean refreshList = false; if (currentParamSessionSortCol == null || requestParamSessionSortCol == null) { listOrder = CmsListOrderEnum.ORDER_ASCENDING; requestParamSessionSortCol = LIST_COLUMN_PATH; } else { if (action.equals(LIST_SORT)) { if (requestParamSessionSortCol.equals(currentParamSessionSortCol)) { refreshList = true; if (currentSessionSortOrder.equals(CmsListOrderEnum.ORDER_ASCENDING)) { listOrder = CmsListOrderEnum.ORDER_DESCENDING; } else { listOrder = CmsListOrderEnum.ORDER_ASCENDING; } } else { listOrder = CmsListOrderEnum.ORDER_ASCENDING; } } else { listOrder = currentSessionSortOrder; } } context.setAttribute("sort_order", listOrder, PageContext.SESSION_SCOPE); context.setAttribute("sort_column", requestParamSessionSortCol, PageContext.SESSION_SCOPE); CmsXmlMockProcessDialog returnObject = new CmsXmlMockProcessDialog( new CmsJspActionElement(context, req, res), LIST_ID, Messages.get().container(Messages.GUI_MOCK_PROCESS_LIST_NAME_0), requestParamSessionSortCol, listOrder, null); if (refreshList) { returnObject.refreshList(); } return returnObject; }
From source file:com.jaspersoft.jasperserver.rest.RESTUtils.java
/** * Look for parameters provided by the client. * * @param req HttpServletRequest//from w w w . j a v a2 s . c om * @return Map<String,Object> */ public static Map<String, Object> extractParameters(HttpServletRequest req) { Map<String, Object> parameters = new HashMap<String, Object>(); Enumeration penum = req.getParameterNames(); while (penum.hasMoreElements()) { String pname = (String) penum.nextElement(); if (pname.startsWith("P_")) { parameters.put(pname.substring(2), req.getParameter(pname)); } else if (pname.startsWith("PL_")) { parameters.put(pname.substring(3), Arrays.asList(req.getParameterValues(pname))); } } return parameters; }
From source file:fr.paris.lutece.plugins.workflow.modules.notifygru.service.Validator.java
/** * Checks if is valide build sms.// ww w .j a v a2s. c o m * * @param request the request * @param config the config * @param providerService the _provider service * @param locale the locale * @param strApply the str apply * @return the string */ public static String isValideBuildSMS(HttpServletRequest request, TaskNotifyGruConfig config, AbstractServiceProvider providerService, Locale locale, String strApply) { String strUrlRedirector = ""; /*sms*/ ArrayList<String> errors = new ArrayList<String>(); String strMessageSMS = request.getParameter(Constants.PARAMETER_MESSAGE_SMS); if (StringUtils.isBlank(strApply)) { if (StringUtils .isNotBlank(Validator.mandotoryParams(strMessageSMS, Constants.MESSAGE_SMS_FIELD, locale))) { errors.add(Validator.mandotoryParams(strMessageSMS, Constants.MESSAGE_SMS_FIELD, locale)); } if (!Validator.isFreemarkerValid(strMessageSMS, locale, providerService.getInfos(-1))) { Object[] tabRequiredFields = { I18nService.getLocalizedString(Constants.MESSAGE_ERROR_FREEMARKER, locale), }; strUrlRedirector = AdminMessageService.getMessageUrl(request, Constants.MESSAGE_ERROR_FREEMARKER, tabRequiredFields, AdminMessage.TYPE_STOP); } } if (!errors.isEmpty()) { strUrlRedirector = ServiceConfigTaskForm.displayErrorMessage(errors, request); } if (StringUtils.isBlank(strUrlRedirector)) { config.setMessageSMS(strMessageSMS); } return strUrlRedirector; }
From source file:br.gov.lexml.server.LexMLOAIHandler.java
public static String getResult(final HashMap attributes, final HttpServletRequest request, final HttpServletResponse response, final Transformer serverTransformer, final HashMap serverVerbs, final HashMap extensionVerbs, final String extensionPath) throws Throwable { try {// w ww . j av a2 s . co m boolean isExtensionVerb = extensionPath.equals(request.getPathInfo()); String verb = request.getParameter("verb"); if (debug) { log.debug("OAIHandler.getResult: verb=>" + verb + "<"); } String result; Class verbClass = null; if (isExtensionVerb) { verbClass = (Class) extensionVerbs.get(verb); } else { verbClass = (Class) serverVerbs.get(verb); } if (verbClass == null) { verbClass = (Class) attributes.get("OAIHandler.missingVerbClass"); } Method construct = verbClass.getMethod("construct", new Class[] { HashMap.class, HttpServletRequest.class, HttpServletResponse.class, Transformer.class }); try { result = (String) construct.invoke(null, new Object[] { attributes, request, response, serverTransformer }); } catch (InvocationTargetException e) { throw e.getTargetException(); } if (debug) { log.debug(result); } return result; } catch (NoSuchMethodException e) { throw new OAIInternalServerError(e.getMessage()); } catch (IllegalAccessException e) { throw new OAIInternalServerError(e.getMessage()); } }
From source file:fr.paris.lutece.plugins.workflow.modules.notifygru.service.Validator.java
/** * Checks if is valide build agent.// w ww .java 2s . c o m * * @param request the request * @param config the config * @param providerService the _provider service * @param locale the locale * @param strApply the str apply * @return the string */ public static String isValideBuildAgent(HttpServletRequest request, TaskNotifyGruConfig config, AbstractServiceProvider providerService, Locale locale, String strApply) { String strUrlRedirector = ""; /*Agent*/ ArrayList<String> errors = new ArrayList<String>(); String strMessageAgent = request.getParameter(Constants.PARAMETER_STATUS_MESSAGE_AGENT); String strStatutTextAgent = request.getParameter(Constants.PARAMETER_STATUS_TEXT_AGENT); if (StringUtils.isBlank(strApply)) { if (StringUtils.isNotBlank( Validator.mandotoryParams(strMessageAgent, Constants.MESSAGE_AGENT_FIELD_MESSAGE, locale))) { errors.add( Validator.mandotoryParams(strMessageAgent, Constants.MESSAGE_AGENT_FIELD_MESSAGE, locale)); } if (StringUtils.isNotBlank( Validator.mandotoryParams(strStatutTextAgent, Constants.MESSAGE_AGENT_FIELD_STATUS, locale))) { errors.add(Validator.mandotoryParams(strStatutTextAgent, Constants.MESSAGE_AGENT_FIELD_STATUS, locale)); } if (!Validator.isFreemarkerValid(strMessageAgent, locale, providerService.getInfos(-1))) { Object[] tabRequiredFields = { I18nService.getLocalizedString(Constants.MESSAGE_ERROR_FREEMARKER, locale), }; strUrlRedirector = AdminMessageService.getMessageUrl(request, Constants.MESSAGE_ERROR_FREEMARKER, tabRequiredFields, AdminMessage.TYPE_STOP); } } if (!errors.isEmpty()) { strUrlRedirector = ServiceConfigTaskForm.displayErrorMessage(errors, request); } if (StringUtils.isBlank(strUrlRedirector)) { config.setMessageAgent(strMessageAgent); config.setStatustextAgent(strStatutTextAgent); } return strUrlRedirector; }
From source file:fr.paris.lutece.plugins.workflow.modules.notifygru.service.Validator.java
/** * Checks if is valide build guichet.//from w w w .ja v a2 s . co m * * @param request the request * @param config the config * @param providerService the _provider service * @param locale the locale * @param strApply the str apply * @return the string */ public static String isValideBuildGuichet(HttpServletRequest request, TaskNotifyGruConfig config, AbstractServiceProvider providerService, Locale locale, String strApply) { String strUrlRedirector = ""; ArrayList<String> errors = new ArrayList<String>(); String strMessageGuichet = request.getParameter(Constants.PARAMETER_MESSAGE_GUICHET); String strStatusTextGuichet = request.getParameter(Constants.PARAMETER_STATUS_TEXT_GUICHET); String strSenderNameGuichet = request.getParameter(Constants.PARAMETER_SENDER_NAME_GUICHET); String strSubjectGuichet = request.getParameter(Constants.PARAMETER_SUBJECT_GUICHET); //optional String strDemandMaxStepGuichet = request.getParameter(Constants.PARAMETER_DEMAND_MAX_STEP_GUICHET); int nDemandMaxStepGuichet = ServiceConfigTaskForm.getNumbertoString(strDemandMaxStepGuichet); String strDemandUserCurrentStepGuichet = request .getParameter(Constants.PARAMETER_DEMAND_USER_CURRENT_STEP_GUICHET); int nDemandUserCurrentStepGuichet = ServiceConfigTaskForm .getNumbertoString(strDemandUserCurrentStepGuichet); if (StringUtils.isBlank(strApply)) { if (StringUtils.isNotBlank(Validator.mandotoryParams(strMessageGuichet, Constants.MESSAGE_MANDATORY_GUICHET_MESSAGE_FIELD, locale))) { errors.add(Validator.mandotoryParams(strMessageGuichet, Constants.MESSAGE_MANDATORY_GUICHET_MESSAGE_FIELD, locale)); } if (StringUtils.isNotBlank(Validator.mandotoryParams(strStatusTextGuichet, Constants.MESSAGE_MANDATORY_GUICHET_STATUS_FIELD, locale))) { errors.add(Validator.mandotoryParams(strStatusTextGuichet, Constants.MESSAGE_MANDATORY_GUICHET_STATUS_FIELD, locale)); } if (StringUtils.isNotBlank(Validator.mandotoryParams(strSenderNameGuichet, Constants.MESSAGE_MANDATORY_GUICHET_SENDER_FIELD, locale))) { errors.add(Validator.mandotoryParams(strSenderNameGuichet, Constants.MESSAGE_MANDATORY_GUICHET_SENDER_FIELD, locale)); } if (StringUtils.isNotBlank(Validator.mandotoryParams(strSubjectGuichet, Constants.MESSAGE_MANDATORY_GUICHET_OBJECT_FIELD, locale))) { errors.add(Validator.mandotoryParams(strSubjectGuichet, Constants.MESSAGE_MANDATORY_GUICHET_OBJECT_FIELD, locale)); } if (!Validator.isFreemarkerValid(strMessageGuichet + ' ' + strSubjectGuichet, locale, providerService.getInfos(-1))) { Object[] tabRequiredFields = { I18nService.getLocalizedString(Constants.MESSAGE_ERROR_FREEMARKER, locale), }; strUrlRedirector = AdminMessageService.getMessageUrl(request, Constants.MESSAGE_ERROR_FREEMARKER, tabRequiredFields, AdminMessage.TYPE_STOP); } } if (!errors.isEmpty()) { strUrlRedirector = ServiceConfigTaskForm.displayErrorMessage(errors, request); } if (StringUtils.isBlank(strUrlRedirector)) { config.setMessageGuichet(strMessageGuichet); config.setStatustextGuichet(strStatusTextGuichet); config.setSenderNameGuichet(strSenderNameGuichet); config.setSubjectGuichet(strSubjectGuichet); config.setDemandMaxStepGuichet(nDemandMaxStepGuichet); config.setDemandUserCurrentStepGuichet(nDemandUserCurrentStepGuichet); } /*fin guichet*/ return strUrlRedirector; }