Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP 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
Marshal
Posts: 34837
369
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic