Java Code Examples for javax.servlet.ServletRequest#getParameterValues()

The following examples show how to use javax.servlet.ServletRequest#getParameterValues() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebUtils.java    From spring-analysis-note with MIT License 6 votes vote down vote up
/**
 * Return a map containing all parameters with the given prefix.
 * Maps single values to String and multiple values to String array.
 * <p>For example, with a prefix of "spring_", "spring_param1" and
 * "spring_param2" result in a Map with "param1" and "param2" as keys.
 * @param request the HTTP request in which to look for parameters
 * @param prefix the beginning of parameter names
 * (if this is null or the empty string, all parameters will match)
 * @return map containing request parameters <b>without the prefix</b>,
 * containing either a String or a String array as values
 * @see javax.servlet.ServletRequest#getParameterNames
 * @see javax.servlet.ServletRequest#getParameterValues
 * @see javax.servlet.ServletRequest#getParameterMap
 */
public static Map<String, Object> getParametersStartingWith(ServletRequest request, @Nullable String prefix) {
	Assert.notNull(request, "Request must not be null");
	Enumeration<String> paramNames = request.getParameterNames();
	Map<String, Object> params = new TreeMap<>();
	if (prefix == null) {
		prefix = "";
	}
	while (paramNames != null && paramNames.hasMoreElements()) {
		String paramName = paramNames.nextElement();
		if (prefix.isEmpty() || paramName.startsWith(prefix)) {
			String unprefixed = paramName.substring(prefix.length());
			String[] values = request.getParameterValues(paramName);
			if (values == null || values.length == 0) {
				// Do nothing, no values found at all.
			}
			else if (values.length > 1) {
				params.put(unprefixed, values);
			}
			else {
				params.put(unprefixed, values[0]);
			}
		}
	}
	return params;
}
 
Example 2
Source File: AsyncTasksTest.java    From appengine-tck with Apache License 2.0 6 votes vote down vote up
@Test
public void testMultiValueParams() throws Exception {
    class ParamHandler implements PrintServlet.RequestHandler {
        private String[] paramValues;

        public void handleRequest(ServletRequest req) {
            paramValues = req.getParameterValues("multi_value");
        }
    }

    ParamHandler handler = new ParamHandler();
    PrintServlet.setRequestHandler(handler);

    final Queue queue = QueueFactory.getQueue("tasks-queue");
    waitOnFuture(queue.addAsync(
        withUrl(URL)
            .param("multi_value", "param_value1")
            .param("multi_value", "param_value2")));
    sync();

    assertNotNull(handler.paramValues);
    assertEquals(
        new HashSet<String>(Arrays.asList("param_value1", "param_value2")),
        new HashSet<String>(Arrays.asList(handler.paramValues)));
}
 
Example 3
Source File: ServletUtils.java    From base-framework with Apache License 2.0 6 votes vote down vote up
/**
 * 通过参数名称获取ServletRequest所有参数
 * 
 * @param request ServletRequest
 * @param name 参数名称
 * 
 * @return List
 */
public static List<String> getParameterValues(ServletRequest request,String name) {
	List<String> list = new ArrayList<String>();
	
	if (request == null || StringUtils.isEmpty(name)) {
		return list;
	}
	
	String[] values = request.getParameterValues(name);
	
	if (ArrayUtils.isNotEmpty(values)) {
		CollectionUtils.addAll(list,values);
	} else {
		String value = request.getParameter(name);
		if (StringUtils.isNotEmpty(value)) {
			values = StringUtils.splitByWholeSeparator(value, ",");
		}
	}
	
	if (values != null && values.length > 0) {
		CollectionUtils.addAll(list,values);
	}
	
	return list;
	
}
 
Example 4
Source File: Servlets.java    From spring-boot-quickstart with Apache License 2.0 6 votes vote down vote up
/**
 * 取得带相同前缀的Request Parameters, copy from spring WebUtils.
 * 
 * 返回的结果的Parameter名已去除前缀.
 */
public static Map<String, Object> getParametersStartingWith(ServletRequest request, String prefix) {
	Validate.notNull(request, "Request must not be null");
	Enumeration paramNames = request.getParameterNames();
	Map<String, Object> params = new TreeMap<String, Object>();
	if (prefix == null) {
		prefix = "";
	}
	while ((paramNames != null) && paramNames.hasMoreElements()) {
		String paramName = (String) paramNames.nextElement();
		if ("".equals(prefix) || paramName.startsWith(prefix)) {
			String unprefixed = paramName.substring(prefix.length());
			String[] values = request.getParameterValues(paramName);
			if ((values == null) || (values.length == 0)) {
				// Do nothing, no values found at all.
			} else if (values.length > 1) {
				params.put(unprefixed, values);
			} else {
				params.put(unprefixed, values[0]);
			}
		}
	}
	return params;
}
 
Example 5
Source File: Servlets.java    From dpCms with Apache License 2.0 6 votes vote down vote up
/**
 * 取得带相同前缀的Request Parameters, copy from spring WebUtils.
 * 
 * 返回的结果的Parameter名已去除前缀.
 */
public static Map<String, Object> getParametersStartingWith(ServletRequest request, String prefix) {
	Validate.notNull(request, "Request must not be null");
	Enumeration paramNames = request.getParameterNames();
	Map<String, Object> params = new TreeMap<String, Object>();
	if (prefix == null) {
		prefix = "";
	}
	if((paramNames != null)) {
		while (paramNames.hasMoreElements()) {
			String paramName = (String) paramNames.nextElement();
			if ("".equals(prefix) || paramName.startsWith(prefix)) {
				String unprefixed = paramName.substring(prefix.length());
				String[] values = request.getParameterValues(paramName);
				if ((values == null) || (values.length == 0)) {
					// Do nothing, no values found at all.
				} else if (values.length > 1) {
					params.put(unprefixed, values);
				} else {
					params.put(unprefixed, values[0]);
				}
			}
		}
	}
	return params;
}
 
Example 6
Source File: WebUtils.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
/**
 * Return a map containing all parameters with the given prefix.
 * Maps single values to String and multiple values to String array.
 * <p>For example, with a prefix of "spring_", "spring_param1" and
 * "spring_param2" result in a Map with "param1" and "param2" as keys.
 * @param request HTTP request in which to look for parameters
 * @param prefix the beginning of parameter names
 * (if this is null or the empty string, all parameters will match)
 * @return map containing request parameters <b>without the prefix</b>,
 * containing either a String or a String array as values
 * @see javax.servlet.ServletRequest#getParameterNames
 * @see javax.servlet.ServletRequest#getParameterValues
 * @see javax.servlet.ServletRequest#getParameterMap
 */
public static Map<String, Object> getParametersStartingWith(ServletRequest request, String prefix) {
	Assert.notNull(request, "Request must not be null");
	Enumeration<String> paramNames = request.getParameterNames();
	Map<String, Object> params = new TreeMap<String, Object>();
	if (prefix == null) {
		prefix = "";
	}
	while (paramNames != null && paramNames.hasMoreElements()) {
		String paramName = paramNames.nextElement();
		if ("".equals(prefix) || paramName.startsWith(prefix)) {
			String unprefixed = paramName.substring(prefix.length());
			String[] values = request.getParameterValues(paramName);
			if (values == null || values.length == 0) {
				// Do nothing, no values found at all.
			}
			else if (values.length > 1) {
				params.put(unprefixed, values);
			}
			else {
				params.put(unprefixed, values[0]);
			}
		}
	}
	return params;
}
 
Example 7
Source File: ServletUtils.java    From DWSurvey with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * 取得带相同前缀的Request Parameters.
 * 
 * 返回的结果的Parameter名已去除前缀.
 */
public static Map<String, Object> getParametersStartingWith(ServletRequest request, String prefix) {
	AssertUtils.notNull(request, "Request must not be null");
	Enumeration paramNames = request.getParameterNames();
	Map<String, Object> params = new TreeMap<String, Object>();
	if (prefix == null) {
		prefix = "";
	}
	while (paramNames != null && paramNames.hasMoreElements()) {
		String paramName = (String) paramNames.nextElement();
		if ("".equals(prefix) || paramName.startsWith(prefix)) {
			String unprefixed = paramName.substring(prefix.length());
			String[] values = request.getParameterValues(paramName);
			if (values == null || values.length == 0) {
				// Do nothing, no values found at all.
			} else if (values.length > 1) {
				params.put(unprefixed, values);
			} else {
				params.put(unprefixed, values[0]);
			}
		}
	}
	return params;
}
 
Example 8
Source File: ServletRequestHandler.java    From commons-jxpath with Apache License 2.0 6 votes vote down vote up
public Object getProperty(Object bean, String property) {
    ServletRequestAndContext handle = (ServletRequestAndContext) bean;
    ServletRequest servletRequest = handle.getServletRequest();
    String[] strings = servletRequest.getParameterValues(property);

    if (strings != null) {
        if (strings.length == 0) {
            return null;
        }
        if (strings.length == 1) {
            return strings[0];
        }
        return strings;
    }

    Object object = servletRequest.getAttribute(property);
    if (object != null) {
        return object;
    }

    return super.getProperty(bean, property);
}
 
Example 9
Source File: WebUtils.java    From java-technology-stack with MIT License 6 votes vote down vote up
/**
 * Return a map containing all parameters with the given prefix.
 * Maps single values to String and multiple values to String array.
 * <p>For example, with a prefix of "spring_", "spring_param1" and
 * "spring_param2" result in a Map with "param1" and "param2" as keys.
 * @param request the HTTP request in which to look for parameters
 * @param prefix the beginning of parameter names
 * (if this is null or the empty string, all parameters will match)
 * @return map containing request parameters <b>without the prefix</b>,
 * containing either a String or a String array as values
 * @see javax.servlet.ServletRequest#getParameterNames
 * @see javax.servlet.ServletRequest#getParameterValues
 * @see javax.servlet.ServletRequest#getParameterMap
 */
public static Map<String, Object> getParametersStartingWith(ServletRequest request, @Nullable String prefix) {
	Assert.notNull(request, "Request must not be null");
	Enumeration<String> paramNames = request.getParameterNames();
	Map<String, Object> params = new TreeMap<>();
	if (prefix == null) {
		prefix = "";
	}
	while (paramNames != null && paramNames.hasMoreElements()) {
		String paramName = paramNames.nextElement();
		if ("".equals(prefix) || paramName.startsWith(prefix)) {
			String unprefixed = paramName.substring(prefix.length());
			String[] values = request.getParameterValues(paramName);
			if (values == null || values.length == 0) {
				// Do nothing, no values found at all.
			}
			else if (values.length > 1) {
				params.put(unprefixed, values);
			}
			else {
				params.put(unprefixed, values[0]);
			}
		}
	}
	return params;
}
 
Example 10
Source File: ServletUtils.java    From base-framework with Apache License 2.0 6 votes vote down vote up
/**
 * 取得带相同前缀的Request Parameters.
 * 
 * 返回的结果的Parameter名已去除前缀.
 */
public static Map<String, Object> getParametersStartingWith(ServletRequest request, String prefix) {
	Assert.notNull(request, "Request must not be null");
	Enumeration paramNames = request.getParameterNames();
	Map<String, Object> params = new TreeMap<String, Object>();
	if (prefix == null) {
		prefix = "";
	}
	while (paramNames != null && paramNames.hasMoreElements()) {
		String paramName = (String) paramNames.nextElement();
		if ("".equals(prefix) || paramName.startsWith(prefix)) {
			String unprefixed = paramName.substring(prefix.length());
			String[] values = request.getParameterValues(paramName);
			if (values == null || values.length == 0) {
				
			} else if (values.length > 1) {
				params.put(unprefixed, values);
			} else {
				params.put(unprefixed, values[0]);
			}
		}
	}
	return params;
}
 
Example 11
Source File: ServletUtils.java    From datax-web with MIT License 6 votes vote down vote up
/**
 * 取得带相同前缀的Request Parameters, copy from spring WebUtils.
 * 返回的结果的Parameter名已去除前缀.
 */
@SuppressWarnings("rawtypes")
public static Map<String, Object> getParametersStartingWith(ServletRequest request, String prefix) {
    Enumeration paramNames = request.getParameterNames();
    Map<String, Object> params = new TreeMap<String, Object>();
    String pre = prefix;
    if (pre == null) {
        pre = "";
    }
    while (paramNames != null && paramNames.hasMoreElements()) {
        String paramName = (String) paramNames.nextElement();
        if ("".equals(pre) || paramName.startsWith(pre)) {
            String unprefixed = paramName.substring(pre.length());
            String[] values = request.getParameterValues(paramName);
            if (values == null || values.length == 0) {
                values = new String[]{};
                // Do nothing, no values found at all.
            } else if (values.length > 1) {
                params.put(unprefixed, values);
            } else {
                params.put(unprefixed, values[0]);
            }
        }
    }
    return params;
}
 
Example 12
Source File: Servlets.java    From easyweb with Apache License 2.0 5 votes vote down vote up
/**
 * 取得带相同前缀的Request Parameters, copy from spring WebUtils.
 * 
 * 返回的结果的Parameter名已去除前缀.
 */
@SuppressWarnings("rawtypes")
public static Map<String, Object> getParametersStartingWith(ServletRequest request, String prefix) {
	Validate.notNull(request, "Request must not be null");
	Enumeration paramNames = request.getParameterNames();
	Map<String, Object> params = new TreeMap<String, Object>();
	String pre = prefix;
	if (pre == null) {
		pre = "";
	}
	while (paramNames != null && paramNames.hasMoreElements()) {
		String paramName = (String) paramNames.nextElement();
		if ("".equals(pre) || paramName.startsWith(pre)) {
			String unprefixed = paramName.substring(pre.length());
			String[] values = request.getParameterValues(paramName);
			if (values == null || values.length == 0) {
				values = new String[]{};
				// Do nothing, no values found at all.
			} else if (values.length > 1) {
				params.put(unprefixed, values);
			} else {
				params.put(unprefixed, values[0]);
			}
		}
	}
	return params;
}
 
Example 13
Source File: WebUtil.java    From hdw-dubbo with Apache License 2.0 5 votes vote down vote up
/**
 * 取得带相同前缀的Request Parameters, copy from spring WebUtils.
 * <p>
 * 返回的结果的Parameter名已去除前缀.
 */
@SuppressWarnings("rawtypes")
public static Map<String, Object> getParametersWith(ServletRequest request, String prefix) {
    Assert.notNull(request, "Request must not be null");
    Enumeration paramNames = request.getParameterNames();
    Map<String, Object> params = new TreeMap<String, Object>();
    String pre = prefix;
    if (pre == null) {
        pre = "";
    }
    while (paramNames != null && paramNames.hasMoreElements()) {
        String paramName = (String) paramNames.nextElement();
        if ("".equals(pre) || paramName.startsWith(pre)) {
            String unprefixed = paramName.substring(pre.length());
            String[] values = request.getParameterValues(paramName);
            if (values == null || values.length == 0) {
                values = new String[]{};
                // Do nothing, no values found at all.
            } else if (values.length > 1) {
                params.put(unprefixed, values);
            } else {
                params.put(unprefixed, values[0]);
            }
        }
    }
    return params;
}
 
Example 14
Source File: Servlets.java    From Shop-for-JavaWeb with MIT License 5 votes vote down vote up
/**
 * 取得带相同前缀的Request Parameters, copy from spring WebUtils.
 * 
 * 返回的结果的Parameter名已去除前缀.
 */
@SuppressWarnings("rawtypes")
public static Map<String, Object> getParametersStartingWith(ServletRequest request, String prefix) {
	Validate.notNull(request, "Request must not be null");
	Enumeration paramNames = request.getParameterNames();
	Map<String, Object> params = new TreeMap<String, Object>();
	String pre = prefix;
	if (pre == null) {
		pre = "";
	}
	while (paramNames != null && paramNames.hasMoreElements()) {
		String paramName = (String) paramNames.nextElement();
		if ("".equals(pre) || paramName.startsWith(pre)) {
			String unprefixed = paramName.substring(pre.length());
			String[] values = request.getParameterValues(paramName);
			if (values == null || values.length == 0) {
				values = new String[]{};
				// Do nothing, no values found at all.
			} else if (values.length > 1) {
				params.put(unprefixed, values);
			} else {
				params.put(unprefixed, values[0]);
			}
		}
	}
	return params;
}
 
Example 15
Source File: ServletUtils.java    From frpMgr with MIT License 5 votes vote down vote up
/**
 * 取得带相同前缀的Request Parameters, copy from spring WebUtils.
 * 返回的结果的Parameter名已去除前缀.
 */
@SuppressWarnings("rawtypes")
public static Map<String, Object> getParametersStartingWith(ServletRequest request, String prefix) {
	Validate.notNull(request, "Request must not be null");
	Enumeration paramNames = request.getParameterNames();
	Map<String, Object> params = new TreeMap<String, Object>();
	String pre = prefix;
	if (pre == null) {
		pre = "";
	}
	while (paramNames != null && paramNames.hasMoreElements()) {
		String paramName = (String) paramNames.nextElement();
		if ("".equals(pre) || paramName.startsWith(pre)) {
			String unprefixed = paramName.substring(pre.length());
			String[] values = request.getParameterValues(paramName);
			if (values == null || values.length == 0) {
				values = new String[]{};
				// Do nothing, no values found at all.
			} else if (values.length > 1) {
				params.put(unprefixed, values);
			} else {
				params.put(unprefixed, values[0]);
			}
		}
	}
	return params;
}
 
Example 16
Source File: JspRuntimeLibrary.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
private static void internalIntrospecthelper(Object bean, String prop,
                                    String value, ServletRequest request,
                                    String param, boolean ignoreMethodNF) 
                                    throws JasperException
{
    Method method = null;
    Class<?> type = null;
    Class<?> propertyEditorClass = null;
    try {
        java.beans.BeanInfo info
            = java.beans.Introspector.getBeanInfo(bean.getClass());
        if ( info != null ) {
            java.beans.PropertyDescriptor pd[]
                = info.getPropertyDescriptors();
            for (int i = 0 ; i < pd.length ; i++) {
                if ( pd[i].getName().equals(prop) ) {
                    method = pd[i].getWriteMethod();
                    type   = pd[i].getPropertyType();
                    propertyEditorClass = pd[i].getPropertyEditorClass();
                    break;
                }
            }
        }
        if ( method != null ) {
            if (type.isArray()) {
                if (request == null) {
                    throw new JasperException(
                        Localizer.getMessage("jsp.error.beans.setproperty.noindexset"));
                }
                Class<?> t = type.getComponentType();
                String[] values = request.getParameterValues(param);
                //XXX Please check.
                if(values == null) return;
                if(t.equals(String.class)) {
                    method.invoke(bean, new Object[] { values });
                } else {
                    createTypedArray (prop, bean, method, values, t,
                                      propertyEditorClass); 
                }
            } else {
                if(value == null || (param != null && value.equals(""))) return;
                Object oval = convert(prop, value, type, propertyEditorClass);
                if ( oval != null )
                    method.invoke(bean, new Object[] { oval });
            }
        }
    } catch (Exception ex) {
        Throwable thr = ExceptionUtils.unwrapInvocationTargetException(ex);
        ExceptionUtils.handleThrowable(thr);
        throw new JasperException(ex);
    }
    if (!ignoreMethodNF && (method == null)) {
        if (type == null) {
            throw new JasperException(
                Localizer.getMessage("jsp.error.beans.noproperty",
                                     prop,
                                     bean.getClass().getName()));
        } else {
            throw new JasperException(
                Localizer.getMessage("jsp.error.beans.nomethod.setproperty",
                                     prop,
                                     type.getName(),
                                     bean.getClass().getName()));
        }
    }
}
 
Example 17
Source File: AbstractMyrrixServlet.java    From myrrix-recommender with Apache License 2.0 4 votes vote down vote up
protected static String[] getRescorerParams(ServletRequest request) {
  String[] rescorerParams = request.getParameterValues("rescorerParams");
  return rescorerParams == null ? NO_PARAMS : rescorerParams;
}
 
Example 18
Source File: JspRuntimeLibrary.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
public static void introspecthelper(Object bean, String prop,
                                    String value, ServletRequest request,
                                    String param, boolean ignoreMethodNF)
                                    throws JasperException {
    Method method = null;
    Class<?> type = null;
    Class<?> propertyEditorClass = null;
    try {
        java.beans.BeanInfo info
            = java.beans.Introspector.getBeanInfo(bean.getClass());
        if ( info != null ) {
            java.beans.PropertyDescriptor pd[]
                = info.getPropertyDescriptors();
            for (int i = 0 ; i < pd.length ; i++) {
                if ( pd[i].getName().equals(prop) ) {
                    method = pd[i].getWriteMethod();
                    type   = pd[i].getPropertyType();
                    propertyEditorClass = pd[i].getPropertyEditorClass();
                    break;
                }
            }
        }
        if ( method != null ) {
            if (type.isArray()) {
                if (request == null) {
                    throw new JasperException(
                        Localizer.getMessage("jsp.error.beans.setproperty.noindexset"));
                }
                Class<?> t = type.getComponentType();
                String[] values = request.getParameterValues(param);
                //XXX Please check.
                if(values == null) return;
                if(t.equals(String.class)) {
                    method.invoke(bean, new Object[] { values });
                } else {
                    createTypedArray (prop, bean, method, values, t,
                                      propertyEditorClass); 
                }
            } else {
                if(value == null || (param != null && value.equals(""))) return;
                Object oval = convert(prop, value, type, propertyEditorClass);
                if ( oval != null )
                    method.invoke(bean, new Object[] { oval });
            }
        }
    } catch (Exception ex) {
        Throwable thr = ExceptionUtils.unwrapInvocationTargetException(ex);
        ExceptionUtils.handleThrowable(thr);
        throw new JasperException(ex);
    }
    if (!ignoreMethodNF && (method == null)) {
        if (type == null) {
            throw new JasperException(
                Localizer.getMessage("jsp.error.beans.noproperty",
                                     prop,
                                     bean.getClass().getName()));
        } else {
            throw new JasperException(
                Localizer.getMessage("jsp.error.beans.nomethod.setproperty",
                                     prop,
                                     type.getName(),
                                     bean.getClass().getName()));
        }
    }
}
 
Example 19
Source File: JspRuntimeLibrary.java    From packagedrone with Eclipse Public License 1.0 4 votes vote down vote up
private static void internalIntrospecthelper(Object bean, String prop,
				String value, ServletRequest request,
				String param, boolean ignoreMethodNF) 
				throws JasperException
   {
       Method method = null;
       Class type = null;
       Class propertyEditorClass = null;
try {
    java.beans.BeanInfo info
	= java.beans.Introspector.getBeanInfo(bean.getClass());
    if ( info != null ) {
	java.beans.PropertyDescriptor pd[]
	    = info.getPropertyDescriptors();
	for (int i = 0 ; i < pd.length ; i++) {
	    if ( pd[i].getName().equals(prop) ) {
		method = pd[i].getWriteMethod();
		type   = pd[i].getPropertyType();
		propertyEditorClass = pd[i].getPropertyEditorClass();
		break;
	    }
	}
    }
    if ( method != null ) {
	if (type.isArray()) {
                   if (request == null) {
		throw new JasperException(
	            Localizer.getMessage("jsp.error.beans.setproperty.noindexset"));
                   }
	    Class t = type.getComponentType();
	    String[] values = request.getParameterValues(param);
	    //XXX Please check.
	    if(values == null) return;
	    if(t.equals(String.class)) {
		method.invoke(bean, new Object[] { values });
	    } else {
		Object tmpval = null;
		createTypedArray (prop, bean, method, values, t,
				  propertyEditorClass); 
	    }
	} else {
	    if(value == null || (param != null && value.equals(""))) return;
	    Object oval = convert(prop, value, type, propertyEditorClass);
	    if ( oval != null )
		method.invoke(bean, new Object[] { oval });
	}
    }
} catch (Exception ex) {
    throw new JasperException(ex);
}
       if (!ignoreMethodNF && (method == null)) {
           if (type == null) {
	throw new JasperException(
                   Localizer.getMessage("jsp.error.beans.noproperty",
				 prop,
				 bean.getClass().getName()));
           } else {
	throw new JasperException(
            Localizer.getMessage("jsp.error.beans.nomethod.setproperty",
				 prop,
				 type.getName(),
				 bean.getClass().getName()));
           }
       }
   }
 
Example 20
Source File: JspRuntimeLibrary.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
public static void introspecthelper(Object bean, String prop,
                                    String value, ServletRequest request,
                                    String param, boolean ignoreMethodNF)
                                    throws JasperException {
    Method method = null;
    Class<?> type = null;
    Class<?> propertyEditorClass = null;
    try {
        java.beans.BeanInfo info
            = java.beans.Introspector.getBeanInfo(bean.getClass());
        if ( info != null ) {
            java.beans.PropertyDescriptor pd[]
                = info.getPropertyDescriptors();
            for (int i = 0 ; i < pd.length ; i++) {
                if ( pd[i].getName().equals(prop) ) {
                    method = pd[i].getWriteMethod();
                    type   = pd[i].getPropertyType();
                    propertyEditorClass = pd[i].getPropertyEditorClass();
                    break;
                }
            }
        }
        if (method != null && type != null) {
            if (type.isArray()) {
                if (request == null) {
                    throw new JasperException(
                        Localizer.getMessage("jsp.error.beans.setproperty.noindexset"));
                }
                Class<?> t = type.getComponentType();
                String[] values = request.getParameterValues(param);
                //XXX Please check.
                if(values == null) return;
                if(t.equals(String.class)) {
                    method.invoke(bean, new Object[] { values });
                } else {
                    createTypedArray (prop, bean, method, values, t,
                                      propertyEditorClass);
                }
            } else {
                if(value == null || (param != null && value.equals(""))) return;
                Object oval = convert(prop, value, type, propertyEditorClass);
                if ( oval != null )
                    method.invoke(bean, new Object[] { oval });
            }
        }
    } catch (Exception ex) {
        Throwable thr = ExceptionUtils.unwrapInvocationTargetException(ex);
        ExceptionUtils.handleThrowable(thr);
        throw new JasperException(ex);
    }
    if (!ignoreMethodNF && (method == null)) {
        if (type == null) {
            throw new JasperException(
                Localizer.getMessage("jsp.error.beans.noproperty",
                                     prop,
                                     bean.getClass().getName()));
        } else {
            throw new JasperException(
                Localizer.getMessage("jsp.error.beans.nomethod.setproperty",
                                     prop,
                                     type.getName(),
                                     bean.getClass().getName()));
        }
    }
}