Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2007

Tip: Looking for answers? Try searching our database.

Passing Javascript array to servlet

Thread view: 
Garg - 08 Feb 2007 06:41 GMT
Hi All,

I am facing one problem if you are having any solution please tell me.

I have to pass an array from javascript to servlet. for this i created
one array and pass that through submitting the form with post method
and i am using request.getParameterValues to get that array. But i am
getting values in the first position of that array and that also comma
separated so that also of no use for me.

Is there any way to pass the value to the Servlet?

Thanks
Tarun Garg
Manish Pandit - 08 Feb 2007 20:01 GMT
> Hi All,
>
[quoted text clipped - 10 lines]
> Thanks
> Tarun Garg

You cannot pass arrays from a form to a servlet. It has to be Strings,
or Binary data (multipart requests). Instead of creating an array, you
can set multiple values for the parameter, and use
getParameterValues( ) to get all values as an array. This is pretty
common for checkbox groups, like:

<FORM>
<P>Check all the colors you like</P>
<LABEL><INPUT TYPE="checkbox" NAME="favcolor" VALUE="red">Red</LABEL>
<LABEL><INPUT TYPE="checkbox" NAME="favcolor" VALUE="green">Green</
LABEL>
<LABEL><INPUT TYPE="checkbox" NAME="favcolor" VALUE="blue">Blue</
LABEL>
</FORM>

As you can see, the name is same (favcolor) with different values. If
Red and Green are selected, the query string will look something like ?
favcolor=red&favcolor=green.

-cheers,
Manish
Garg - 10 Feb 2007 05:57 GMT
Thanks Manish, for this valuable information.

I will try this and let you about the result.

thanks once again.

Tarun


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.