JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 13th, 2001, 12:45 PM
spdevshed spdevshed is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2001
Posts: 22 spdevshed User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question javascript array to java

Is it possible to pass an array in javascript to java or a java applet?

thanks

Reply With Quote
  #2  
Old August 15th, 2001, 04:10 AM
rycamor rycamor is offline
Gödelian monster
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jul 1999
Location: Central Florida, USA
Posts: 2,306 rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 6 h 42 m 51 sec
Reputation Power: 60
Being a Java newbie, I can't give you a definitive on how to pass the array to a client-side applet, although it should be possible.

As for passing it to something server-side there are only a couple ways: in a GET request on the query string or in a POST. No matter what, you will have to flatten the array with some method or other, to convert it into a text string that can be parsed on the other end.

I personally favor using hidden form elements and posting the data, because otherwise you have to worry about urlencoding your query string. You could just use javascript itself to write a series of hidden text inputs and then submit the form, so all your form handler has to do is pick up the variables.

Let's say the array is named "myarray":

Code:
<script language="Javascript">

document.writeln("<form name=\"myform\" method=\"POST\" action=\"myserver/myhandler.jsp\">")

for(i = 0; i < myarray.length; i++){
  document.writeln("<input type=\"hidden\" name=\"myarray[" + i + "]\" value=\"" + myarray[i] + "\">")
  }

document.writeln("</form>")
document.myform.submit()

</script>


I know this is clunky and "low-tech" but it will work, and has the benefit of working for any server-side platform that can handle forms.
__________________
The real n-tier system:

FreeBSD -> PostgreSQL -> [any_language] -> Apache -> Mozilla/XUL

Amazon wishlist -- rycamor (at) gmail.com

Reply With Quote
  #3  
Old August 15th, 2001, 05:16 AM
spdevshed spdevshed is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2001
Posts: 22 spdevshed User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
thanks, I will give this a try

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > javascript array to java

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap