List of usage examples for javax.servlet.http HttpServletRequest getParameterNames
public Enumeration<String> getParameterNames();
Enumeration
of String
objects containing the names of the parameters contained in this request. From source file:com.opendesign.utils.ControllerUtil.java
/** * Request ? ? ? Map ? ?. ?? ? java.util.Array ?. * /*ww w . j a v a2 s. c o m*/ * @param request * @return */ public static Map<String, Object> createParamMap(HttpServletRequest request) { Map<String, Object> paramMap = new HashMap<String, Object>(); // 2015.09.13 joldo // String updateID = SessionManager.getAdminId(request.getSession()); // String token = request.getParameter("token"); // paramMap.put("updateID", StringUtils.isEmpty(updateID) ? // "${anonymous}" : updateID ); // paramMap.put("token", StringUtils.isEmpty(token) ? "${anonymous}" : // token ); @SuppressWarnings("rawtypes") Enumeration enums = request.getParameterNames(); while (enums.hasMoreElements()) { String paramName = (String) enums.nextElement(); String[] parameters = request.getParameterValues(paramName); // Parameter ? if (parameters.length > 1) { for (int i = 0; i < parameters.length; i++) { String param = StringUtils.stripToEmpty(parameters[i]); parameters[i] = param; } paramMap.put(paramName, parameters); // Parameter ? } else { paramMap.put(paramName, StringUtils.stripToEmpty(parameters[0])); } } request.setAttribute("param_map", paramMap); return paramMap; }
From source file:com.lm.lic.manager.util.GenUtil.java
/** * @param request//ww w . j ava 2s . c o m */ @SuppressWarnings("unchecked") public static void debugRequestParams(HttpServletRequest request) { Enumeration<String> en = request.getParameterNames(); while (en.hasMoreElements()) { String p = en.nextElement(); String v = request.getParameter(p); System.out.println("\nPARAM: " + p); System.out.println("VALUE: " + v); } en = request.getHeaderNames(); while (en.hasMoreElements()) { String p = en.nextElement(); String v = request.getParameter(p); System.out.println("\nPHEADER: " + p); System.out.println("VALUE: " + v); } String qs = request.getQueryString(); System.out.println("QueryString: " + qs); String method = request.getMethod(); System.out.println("Method: " + method); }
From source file:fr.paris.lutece.portal.web.PortalJspBean.java
/** * Set the upload filter site next url//from w ww .jav a2 s . com * @param request the HTTP request */ public static void setUploadFilterSiteNextUrl(HttpServletRequest request) { String strNextUrl = request.getRequestURI(); UrlItem url = new UrlItem(strNextUrl); Enumeration enumParams = request.getParameterNames(); while (enumParams.hasMoreElements()) { String strParamName = (String) enumParams.nextElement(); url.addParameter(strParamName, request.getParameter(strParamName)); } HttpSession session = request.getSession(true); session.setAttribute(ATTRIBUTE_UPLOAD_FILTER_SITE_NEXT_URL, url.getUrl()); }
From source file:fr.paris.lutece.portal.web.PortalJspBean.java
/** * This method is called by Portal.jsp when it caught an * UserNotSignedException.//from w ww . j a v a 2s . c o m * It gives the login url and stores in the session the url asked * @param request The HTTP request * @return The login page URL * @since v1.1 */ public static String redirectLogin(HttpServletRequest request) { String strNextUrl = request.getRequestURI(); UrlItem url = new UrlItem(strNextUrl); Enumeration enumParams = request.getParameterNames(); while (enumParams.hasMoreElements()) { String strParamName = (String) enumParams.nextElement(); url.addParameter(strParamName, request.getParameter(strParamName)); } HttpSession session = request.getSession(true); session.setAttribute(ATTRIBUTE_LOGIN_NEXT_URL, url.getUrl()); String strRedirect = SecurityService.getInstance().getLoginPageUrl(); return AppPathService.getAbsoluteUrl(request, strRedirect); }
From source file:com.jolira.testing.CachingRESTProxy.java
private static Map<String, String[]> getSortedParameters(final HttpServletRequest request) { final Map<String, String[]> params = new TreeMap<String, String[]>(); @SuppressWarnings("unchecked") final Enumeration<String> names = request.getParameterNames(); if (names == null) { return params; }// w w w. jav a 2 s. c om while (names.hasMoreElements()) { final String name = names.nextElement(); final String[] vals = request.getParameterValues(name); params.put(name, vals); } return params; }
From source file:fr.paris.lutece.plugins.mylutece.web.MyLuteceApp.java
/** * Set the current url//from www. j a v a2s . c o m * @param request The Http request * */ public static void setCurrentUrl(HttpServletRequest request) { String strCurrentUrl = request.getRequestURI(); UrlItem url = new UrlItem(strCurrentUrl); Enumeration enumParams = request.getParameterNames(); while (enumParams.hasMoreElements()) { String strParamName = (String) enumParams.nextElement(); url.addParameter(strParamName, request.getParameter(strParamName)); } HttpSession session = request.getSession(true); session.setAttribute(ATTRIBUTE_CURRENT_URL, url.getUrl()); }
From source file:ste.web.beanshell.jetty.BeanShellUtils.java
public static void setup(final Interpreter interpreter, final HttpServletRequest request, final HttpServletResponse response) throws EvalError, IOException { ///*from w w w. j ava2 s . c o m*/ // Set attributes as script variables // String k, key; for (Enumeration e = request.getAttributeNames(); e.hasMoreElements();) { k = (String) e.nextElement(); key = normalizeVariableName(k); interpreter.set(key, request.getAttribute(k)); } // // Set request parameters as script variables. Note that parameters // override attributes // for (Enumeration e = request.getParameterNames(); e.hasMoreElements();) { k = (String) e.nextElement(); key = normalizeVariableName(k); interpreter.set(key, request.getParameter(k)); } interpreter.set(VAR_REQUEST, request); interpreter.set(VAR_RESPONSE, response); interpreter.set(VAR_SESSION, request.getSession(false)); interpreter.set(VAR_OUT, response.getWriter()); interpreter.set(VAR_LOG, log); if (hasJSONBody(request)) { interpreter.set(VAR_BODY, getJSONBody(request.getInputStream())); } }
From source file:jeeves.server.sources.ServiceRequestFactory.java
@SuppressWarnings("unchecked") private static Element extractParameters(HttpServletRequest req, String uploadDir, int maxUploadSize) throws Exception { //--- set parameters from multipart request if (ServletFileUpload.isMultipartContent(req)) return getMultipartParams(req, uploadDir, maxUploadSize); Element params = new Element(Jeeves.Elem.REQUEST); //--- add parameters from POST request for (Enumeration<String> e = req.getParameterNames(); e.hasMoreElements();) { String name = e.nextElement(); String values[] = req.getParameterValues(name); //--- we don't overwrite params given in the url if (!name.equals("")) if (params.getChild(name) == null) for (int i = 0; i < values.length; i++) params.addContent(new Element(name).setText(values[i])); }/*from w ww. j a v a2 s. c o m*/ return params; }
From source file:com.netsteadfast.greenstep.util.SimpleUtils.java
public static String getHttpRequestUrl(HttpServletRequest request) { StringBuilder url = new StringBuilder(); url.append(request.getRequestURL().toString()); Enumeration<String> paramNames = request.getParameterNames(); for (int i = 0; paramNames.hasMoreElements(); i++) { String paramName = paramNames.nextElement(); if (i == 0) { url.append("?"); } else {/* w w w . j a v a 2s . c o m*/ url.append("&"); } url.append(paramName).append("=").append(request.getParameter(paramName)); } return url.toString(); }
From source file:com.lily.dap.web.util.Struts2Utils.java
/** * /*from w w w . j a v a 2s . c o m*/ * * @param t * @param allowModifyFields * @return nullnull */ @SuppressWarnings("unchecked") public static <T extends BaseEntity> T writeModel(T t, String[] allowModifyFields) { if (t != null) { Map<String, String> parameters = new HashMap<String, String>(); HttpServletRequest request = getRequest(); Enumeration enumeration = request.getParameterNames(); while (enumeration.hasMoreElements()) { String paramName = (String) enumeration.nextElement(); if (allowModifyFields != null && !ArrayUtils.contains(allowModifyFields, paramName)) continue; String paramValue = request.getParameter(paramName); parameters.put(paramName, paramValue); } // getMapper().map(parameters, t); String[] rules = parameters.keySet().toArray(new String[0]); TransferUtils.copy(rules, parameters, t, null); } return t; }