aspose file tools*
The moose likes JSP and the fly likes passing string array to action parameter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "passing string array to action parameter" Watch "passing string array to action parameter" New topic
Author

passing string array to action parameter

Gajen Pingalkar
Ranch Hand

Joined: Aug 29, 2006
Posts: 37
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 29287
    
140

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: passing string array to action parameter
 
Similar Threads
Converting String to an array.
regarding overloaded methods of var args
exceptions and type casting confusion
What is the input file?
help with how to call from JPA oracle stored procedure with array as IN parameter