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:doc.action.SelectedDocsUtils.java
public static Collection saveSelectedDocsIDs(HttpServletRequest request) { //System.out.println("start"); Collection documents = (Collection) request.getSession().getAttribute(Constant.SELECTED_PRESIDENTS); //System.out.println(documents); if (documents == null) { documents = new ArrayList(); request.getSession().setAttribute(Constant.SELECTED_PRESIDENTS, documents); }/* w ww .j a va2s . c o m*/ Enumeration parameterNames = request.getParameterNames(); while (parameterNames.hasMoreElements()) { String parameterName = (String) parameterNames.nextElement(); if (parameterName.startsWith("chkbx_")) { String docId = StringUtils.substringAfter(parameterName, "chkbx_"); String parameterValue = request.getParameter(parameterName); if (parameterValue.equals(Constant.SELECTED)) { if (!documents.contains(docId)) { documents.add(docId); } } else { documents.remove(docId); } } } return documents; }
From source file:co.edu.UNal.ArquitecturaDeSoftware.Bienestar.Vista.App.Usuario.Read.java
protected static void registrarUsuarioConvocatoria(HttpServletRequest request, HttpServletResponse response) throws IOException { /*Enumeration<String> parameterNames = request.getParameterNames(); String param;/*from ww w . java 2 s . c om*/ while(parameterNames.hasMoreElements()){ param = parameterNames.nextElement(); System.out.print(param); System.out.print(": "); System.out.print(request.getParameter(param)); }*/ ArrayList r = CtrlUsuario.registrarAConvocatoriaUsuario(Integer.parseInt(request.getParameter("1")), Integer.parseInt(request.getParameter("2"))); // parameter 1: idUsuario param2: idConv response.setContentType("application/json;charset=UTF-8"); PrintWriter out = response.getWriter(); if (r.get(0) == "error") { JSONObject obj = new JSONObject(); obj.put("isError", true); obj.put("errorDescrip", r.get(1)); out.print(obj); } else if (r.get(0) == "isExitoso") { JSONObject obj = new JSONObject(); obj.put("Exitoso", true); out.print(obj); } else { Util.errordeRespuesta(r, out); } }
From source file:com.gtwm.pb.servlets.ServletUtilMethods.java
/** * Replacement for and wrapper around/*from ww w. jav a 2s . com*/ * HttpServletRequest.getParameter(String) which works for multi-part form * data as well as normal requests */ public static String getParameter(HttpServletRequest request, String parameterName, List<FileItem> multipartItems) { if (FileUpload.isMultipartContent(new ServletRequestContext(request))) { for (FileItem item : multipartItems) { if (item.getFieldName().equals(parameterName)) { if (item.isFormField()) { return item.getString(); } else { return item.getName(); } } } return null; } else { return request.getParameter(parameterName); } }
From source file:fr.paris.lutece.plugins.workflow.modules.notifygru.service.Validator.java
/** * Checks if is valide build email./*from ww w .j a va 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 isValideBuildEmail(HttpServletRequest request, TaskNotifyGruConfig config, AbstractServiceProvider providerService, Locale locale, String strApply) { String strUrlRedirector = ""; /*email*/ ArrayList<String> errors = new ArrayList<String>(); String strSubjectEmail = request.getParameter(Constants.PARAMETER_SUBJECT_EMAIL); String strMessageEmail = request.getParameter(Constants.PARAMETER_MESSAGE_EMAIL); String strSenderNameEmail = request.getParameter(Constants.PARAMETER_SENDER_NAME_EMAIL); String strRecipientsCcEmail = request.getParameter(Constants.PARAMETER_RECIPIENT_CC_EMAIL); String strRecipientsCciEmail = request.getParameter(Constants.PARAMETER_RECIPIENT_CCI_EMAIL); if (StringUtils.isBlank(strApply)) { if (StringUtils.isNotBlank( Validator.mandotoryParams(strSubjectEmail, Constants.MESSAGE_EMAIL_SUBJECT_FIELD, locale))) { errors.add( Validator.mandotoryParams(strSubjectEmail, Constants.MESSAGE_EMAIL_SUBJECT_FIELD, locale)); } if (StringUtils.isNotBlank(Validator.mandotoryParams(strSenderNameEmail, Constants.MESSAGE_EMAIL_SENDER_NAME_FIELD, locale))) { errors.add(Validator.mandotoryParams(strSenderNameEmail, Constants.MESSAGE_EMAIL_SENDER_NAME_FIELD, locale)); } if (StringUtils.isNotBlank( Validator.mandotoryParams(strMessageEmail, Constants.MESSAGE_EMAIL_MESSAGE_FIELD, locale))) { errors.add( Validator.mandotoryParams(strMessageEmail, Constants.MESSAGE_EMAIL_MESSAGE_FIELD, locale)); } if (!Validator.isFreemarkerValid(strMessageEmail + ' ' + strSubjectEmail, 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.setSubjectEmail(strSubjectEmail); config.setMessageEmail(strMessageEmail); config.setSenderNameEmail(strSenderNameEmail); config.setRecipientsCcEmail(strRecipientsCcEmail); config.setRecipientsCciEmail(strRecipientsCciEmail); } return strUrlRedirector; }
From source file:fr.paris.lutece.plugins.workflow.modules.notifygru.service.Validator.java
/** * Checks if is valide build broadcast.//w w w. j a v a 2 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 isValideBuildBroadcast(HttpServletRequest request, TaskNotifyGruConfig config, AbstractServiceProvider providerService, Locale locale, String strApply) { String strUrlRedirector = ""; ArrayList<String> errors = new ArrayList<String>(); String strIdMailingListBroadcast = request.getParameter(Constants.PARAMETER_ID_MAILING_LIST); int nIdMailingListBroadcast = (strIdMailingListBroadcast == null) ? WorkflowUtils.CONSTANT_ID_NULL : Integer.parseInt(strIdMailingListBroadcast); String strsenderNameBroadcast = request.getParameter(Constants.PARAMETER_SENDER_NAME_BROADCAST); String strsubjectBroadcast = request.getParameter(Constants.PARAMETER_SUBJECT_BROADCAST); String strmessageBroadcast = request.getParameter(Constants.PARAMETER_MESSAGE_BROADCAST); String strrecipientsCcBroadcast = request.getParameter(Constants.PARAMETER_RECIPIENT_CC_BROADCAST); String strrecipientsCciBroadcast = request.getParameter(Constants.PARAMETER_RECIPIENT_CCI_BROADCAST); if (StringUtils.isBlank(strApply)) { if (StringUtils.isNotBlank(Validator.mandotoryParams(strIdMailingListBroadcast, Constants.MESSAGE_LIST_ID_LISTE, locale))) { errors.add(Validator.mandotoryParams(strIdMailingListBroadcast, Constants.MESSAGE_LIST_ID_LISTE, locale)); } if (StringUtils.isNotBlank(Validator.mandotoryParams(strsenderNameBroadcast, Constants.MESSAGE_LIST_SENDER_NAME_FIELD, locale))) { errors.add(Validator.mandotoryParams(strsenderNameBroadcast, Constants.MESSAGE_LIST_SENDER_NAME_FIELD, locale)); } if (StringUtils.isNotBlank( Validator.mandotoryParams(strsubjectBroadcast, Constants.MESSAGE_LIST_SUBJECT_FIELD, locale))) { errors.add(Validator.mandotoryParams(strsubjectBroadcast, Constants.MESSAGE_LIST_SUBJECT_FIELD, locale)); } if (StringUtils.isNotBlank( Validator.mandotoryParams(strmessageBroadcast, Constants.MESSAGE_LIST_MESSAGE_FIELD, locale))) { errors.add(Validator.mandotoryParams(strmessageBroadcast, Constants.MESSAGE_LIST_MESSAGE_FIELD, locale)); } if (!Validator.isFreemarkerValid(strmessageBroadcast + ' ' + strsubjectBroadcast, 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); } /* fin liste diffusion*/ if (StringUtils.isBlank(strUrlRedirector)) { config.setIdMailingListBroadcast(nIdMailingListBroadcast); config.setSenderNameBroadcast(strsenderNameBroadcast); config.setSubjectBroadcast(strsubjectBroadcast); config.setMessageBroadcast(strmessageBroadcast); config.setRecipientsCcBroadcast(strrecipientsCcBroadcast); config.setRecipientsCciBroadcast(strrecipientsCciBroadcast); } return strUrlRedirector; }
From source file:com.salesmanager.core.util.LocaleUtil.java
public static void setLocaleForRequest(HttpServletRequest request, HttpServletResponse response, ActionContext ctx, MerchantStore store) throws Exception { /**//w w w. j a v a 2s.c o m * LOCALE */ Map sessions = ctx.getSession(); if (ctx == null) { throw new Exception("This request was not made inside Struts request, ActionContext is null"); } Locale locale = null; // check in http request String req_locale = (String) request.getParameter("request_locale"); if (!StringUtils.isBlank(req_locale)) { String l = null; String c = null; if (req_locale.length() == 2) {//assume it is the language l = req_locale; c = CountryUtil.getCountryIsoCodeById(store.getCountry()); } if (req_locale.length() == 5) { try { l = req_locale.substring(0, 2); c = req_locale.substring(3); } catch (Exception e) { log.warn("Invalid locale format " + req_locale); l = null; c = null; } } if (l != null && c != null) { String storeLang = null; Map languages = store.getGetSupportedLanguages(); if (languages != null && languages.size() > 0) { Iterator i = languages.keySet().iterator(); while (i.hasNext()) { Integer langKey = (Integer) i.next(); Language lang = (Language) languages.get(langKey); if (lang.getCode().equals(l)) { storeLang = l; break; } } } if (storeLang == null) { l = store.getDefaultLang(); if (StringUtils.isBlank(l)) { l = LanguageUtil.getDefaultLanguage(); } } locale = new Locale(l, c); if (StringUtils.isBlank(locale.getLanguage()) || StringUtils.isBlank(locale.getCountry())) { log.error("Language or Country is not set in the new locale " + req_locale); return; } sessions.put("WW_TRANS_I18N_LOCALE", locale); } } locale = (Locale) sessions.get("WW_TRANS_I18N_LOCALE"); request.getSession().setAttribute("WW_TRANS_I18N_LOCALE", locale); if (locale == null) { String c = CountryUtil.getCountryIsoCodeById(store.getCountry()); String lang = store.getDefaultLang(); if (!StringUtils.isBlank(c) && !StringUtils.isBlank(lang)) { locale = new Locale(lang, c); } else { locale = LocaleUtil.getDefaultLocale(); String langs = store.getSupportedlanguages(); if (!StringUtils.isBlank(langs)) { Map languages = store.getGetSupportedLanguages(); String defaultLang = locale.getLanguage(); if (languages != null && languages.size() > 0) { Iterator i = languages.keySet().iterator(); String storeLang = ""; while (i.hasNext()) { Integer langKey = (Integer) i.next(); Language l = (Language) languages.get(langKey); if (l.getCode().equals(defaultLang)) { storeLang = defaultLang; break; } } if (!storeLang.equals(defaultLang)) { defaultLang = storeLang; } } if (!StringUtils.isBlank(defaultLang) && !StringUtils.isBlank(c)) { locale = new Locale(defaultLang, c); } } } sessions.put("WW_TRANS_I18N_LOCALE", locale); } if (locale != null) { LabelUtil label = LabelUtil.getInstance(); label.setLocale(locale); String lang = label.getText("label.language." + locale.getLanguage()); request.setAttribute("LANGUAGE", lang); } if (store.getLanguages() == null || store.getLanguages().size() == 0) { // languages if (!StringUtils.isBlank(store.getSupportedlanguages())) { List languages = new ArrayList(); List langs = LanguageUtil.parseLanguages(store.getSupportedlanguages()); for (Object o : langs) { String lang = (String) o; Language l = LanguageUtil.getLanguageByCode(lang); if (l != null) { l.setLocale(locale, store.getCurrency()); languages.add(l); } } store.setLanguages(languages); } } request.setAttribute("LOCALE", locale); Cookie c = new Cookie("LOCALE", locale.getLanguage() + "_" + locale.getCountry()); c.setPath("/"); c.setMaxAge(2 * 24 * 24); response.addCookie(c); }
From source file:de.betterform.agent.web.WebUtil.java
/** * fetches the XFormsSession from the HTTP Session * * @param request the HTTP Request//ww w . j av a2 s. c o m * @return the xformsSession for the request */ public static WebProcessor getWebProcessor(HttpServletRequest request, HttpServletResponse response, HttpSession session) { // String key = request.getParameter("sessionKey"); // XFormsSessionManager manager = (XFormsSessionManager) session.getAttribute(XFormsSessionManager.XFORMS_SESSION_MANAGER); // XFormsSession xFormsSession = manager.getWebProcessor(key); String key = request.getParameter("sessionKey"); if (key == null) { LOGGER.warn("Request " + request + " has no parameter session key"); return null; } else { return getWebProcessor(key, request, response, session); } }
From source file:org.itracker.web.util.LoginUtilities.java
public static int getRequestAuthType(HttpServletRequest request) { int authType = AuthenticationConstants.AUTH_TYPE_UNKNOWN; try {//from w w w . j a va 2 s . c o m if (request.getAttribute(Constants.AUTH_TYPE_KEY) != null) { authType = (Integer) request.getAttribute(Constants.AUTH_TYPE_KEY); } if (request.getParameter(Constants.AUTH_TYPE_KEY) != null) { authType = Integer.valueOf(request.getParameter(Constants.AUTH_TYPE_KEY)); } } catch (Exception e) { logger.debug("Error retrieving auth type while checking auto login. " + e.getMessage()); } return authType; }
From source file:com.healthcit.analytics.utils.CAHopeDataSourceUtils.java
/** * Returns a JSONArray that contains some metadata about the columns. * Currrently includes information about the column name and data type. *///w ww . j av a 2 s .com public static List<Map<String, Object>> getColumnData(HttpServletRequest request) { // if there is no "orderedColumnNames" request parameter then return null if (StringUtils.isBlank(Constants.ORDERED_COLUMN_NAMES)) return null; // else, set up a JSONArray containing metadata about the columns // JSONArray columnDataArray = new JSONArray(); ArrayList<Map<String, Object>> columnDataArray = new ArrayList<Map<String, Object>>(); // get the full list of columns in the request String[] allColumns = request.getParameter(Constants.ORDERED_COLUMN_NAMES).split(SPLITTER); // get the list of numeric columns in the request String[] numericColumns = StringUtils.split(request.getParameter(Constants.NUMERIC_DATA_TYPE)); // get the list of boolean columns in the request String[] booleanColumns = StringUtils.split(request.getParameter(Constants.BOOLEAN_DATA_TYPE)); // get the list of date columns in the request String[] dateColumns = StringUtils.split(request.getParameter(Constants.DATE_DATA_TYPE)); // associate column data types with each column for (String column : allColumns) { // get the column data type ValueType columnDataType = getColumnDataType(column, numericColumns, booleanColumns, dateColumns); // create a JSONObject representing metadata for this column // JSONObject columnMetaData = new JSONObject(); // // columnMetaData.put( NAME, column ); // // columnMetaData.put( TYPE, columnDataType ); // // columnDataArray.add( columnMetaData ); Map<String, Object> columnMetaData = new HashMap<String, Object>(); columnMetaData.put(NAME, column); columnMetaData.put(TYPE, columnDataType); columnDataArray.add(columnMetaData); } // return the JSON object return columnDataArray; }
From source file:net.duckling.ddl.util.ResourceQuery.java
public static ResourceQuery buildForQuery(HttpServletRequest request) { String order = request.getParameter("sortType"); order = StringUtils.isEmpty(order) ? "timeDesc" : order; return buildForQuery(request, order); }