Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

passing string array to action parameter

 
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: 35762
412
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's a pleasure to see superheros taking such an interest in science. And this tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!