Java
A servlet snippet to get all URL parameters into an array of Strings
//At the end of this snippet, mParamList will consist of an array of Strings of name value pairs where the names are the URL parameter names, and the values are their values. Useful for passing into MATLAB, for example.
// a vector to hold all the request parameter, this will be dynamically allocated
// then later copied into a String array to pass to the Java code
Vector mParamList_Vector = new Vector();
try {
String[] results = null;
//get all parameters from the url and add to the mParamList
Enumeration paramNames = request.getParameterNames();
int i =0;
while(paramNames.hasMoreElements()) {
String paramName = (String)paramNames.nextElement();
String[] paramValues = request.getParameterValues(paramName);
mParamList_Vector.addElement(paramName);
mParamList_Vector.addElement(paramValues[0]);
}
//copy vector into String array
int count = mParamList_Vector.size();
String[] mParamList = new String[count];
mParamList_Vector.copyInto(mParamList);
for(i=0; i<mParamList.length-1;i+=2)
System.out.println("Parameter "+ mParamList[i]+ " ------- Value: " + mParamList[i+1]);
}
catch(Exception e){
System.out.println(e.getMessage());
}