Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

php form arrays in java  RSS feed

 
Arian Hojat
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was wondering if you could do this in java which i currently do similar things in php.

I have a bunch of parameters to a jsp I want to pass over from a html form.
usually I do something like:
xxx.jsp?page=1&type=html&reloadReport=true&startDate=2/7/2003&endDate=2/7/2003&firstName=John

Since the jsp should be generic (it takes params and adds them to a java reporting class to create a report), i dont want to add every param passed to the jsp as a parameter.
Basically I only want the ones i flag to end up being passed...

In php, I would do something like this on the form,
have my regular variables that would always be processed in their own form variables to pass like:
test.php?page=1&type=html&reloadReport=true
but then for all the ones that will be lumped together, put them in an array so they can be 'thrown' to 1 generic process/function:
test.php?page=1&reloadReport=true¶ms[startDate]=2/7/2003¶ms[endDate]=2/7/2003¶ms[firstName]=John
and easily loop over to put in array
foreach( $_GET['params'] as $key=>$val)
{
$params[$key] = $value;
}
createReport($params);

But I wasn't sure if when you request GET params like so...
String reporttype = request.getParameter("params");
...if it will recognize and automatically put the key/values into an array?
So i want java to do soemthing like above but not sure if possible:
Map parameters = new HashMap();
ArrayList params = (ArrayList) request.getParameter("params");
for( String key=>value : params )
{
parameters.put( key, value );
}

[ September 25, 2007: Message edited by: Arian Hojat ]
[ September 25, 2007: Message edited by: Arian Hojat ]
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to our JSP forum...
 
Arian Hojat
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
bump
doh, looks like the 'moving to JSP forum' post counted as a reply,
maybe people assumed it got solved by someone...

Anyone?
 
Tarun Yadav
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Arian Hojat:
bump
doh, looks like the 'moving to JSP forum' post counted as a reply,
maybe people assumed it got solved by someone...

Anyone?


Are you looking for this? HttpServletRequest.getParameterMap() and you could also take a look at HttpServletRequest.getParameterNames()

Hope this helps...otherwise I haven't understood what you were asking!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!