Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

passing string array to action parameter  RSS feed

 
Gajen Pingalkar
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my application i have set string array in
String arr[]= {"1","2"}
request.setAttribute("candidate",arr);
and using this attribute now i m passing this array to action parameter in next jsp
<html:form action=/candidate.do?method=success&candidate=${candidate}>

and getting these values in my action servlet by this way,
String arr[]=request.getParameterValues("candidate");

will it work? if not then how to pass array in action parameter?
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36396
453
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gajendra,

This part will not work. The browser needs the URL to look like this to interpret the parameters correctly:
/candidate.do?method=success&candidate=1&candidate=2&candidate=3

You could write an object to create the parameter list of this form and put that in the session instead of the String[] directly.


This part will work if part I is done correctly.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!