Re: What is the best practice for dynamically extracting form data from a request (without extracting each parameter explicitly by name)?
Posted By:
Ganesh_Kumar
Posted On:
Friday, June 10, 2005 07:15 AM
Enumeration en ;
int i=0;
if(request.getParameterNames()!=null){
en = request.getParameterNames();
while(en.hasMoreElements()){
String name = (String)en.nextElement();
String value= request.getParameter(name);
System.out.println("NAME ::: "+name);
System.out.println("value ::: "+value);
if(value.trim().equals("")){
//handel errors
ActionErrors ae = new ActionErrors();
request.setAttribute(Action.ERROR_KEY, ae);
if (ae != null || ae.size( ) > 0) {
return mapping.findForward("failure");
}
}
i++;
}
Re: What is the best practice for dynamically extracting form data from a request (without extracting each parameter explicitly by name)?
Posted By:
Manjula_Kote
Posted On:
Sunday, March 28, 2004 10:01 PM
If the names of request parameters are unknown you can use the method
"Enumeration getParameterNames()" to obtain an enumeration of all parameter names and then iteration over each element and call "getParameter()" or "getParamterValues()" on that method.
Re: What is the best practice for dynamically extracting form data from a request (without extracting each parameter explicitly by name)?
Posted By:
Kedar_Khanvilkar
Posted On:
Tuesday, May 27, 2003 10:33 AM
did you try getParameterNames() and getParameterValues(java.lang.String name) on ServletRequest? Hope I am getting your question right.
-K
Re: What is the best practice for dynamically extracting form data from a request (without extracting each parameter explicitly by name)?
Posted By:
Jeff_Hubbach
Posted On:
Tuesday, December 10, 2002 08:56 AM
We do something very similar on some of our web apps. What we do is have a hidden field listing the ids in comma-delimited format. That enables us to use a StringTokenizer on that list, iterate over it, and get out each pertinent value for each id (ie, quantity, age, etc). This solves your problem by making all your form fields known, you just have to concatenate age or job with whatever id you are on in the list.