NEED HELP: Passing a Java String array to JavaScript


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: NEED HELP: Passing a Java String array to JavaScript

  1. #1
    Gugo Guest

    NEED HELP: Passing a Java String array to JavaScript


    Hi,

    This might not be the right discussion forum (it was either this or Java),
    but I need to pass a String array from Java (JSP) to JavaScript...

    Any ideas?

    Thanks in advance.

  2. #2
    Bronwyn Streeter Guest

    Re: NEED HELP: Passing a Java String array to JavaScript

    You could possibly place the array in a cookie. That way they can both
    access it.

    Gugo <gugo46@hotmail.com> wrote in message
    news:3c03f1b3$1@147.208.176.211...

    Hi,

    This might not be the right discussion forum (it was either this or Java),
    but I need to pass a String array from Java (JSP) to JavaScript...

    Any ideas?

    Thanks in advance.



  3. #3
    Rajeev Sah Guest

    Re: NEED HELP: Passing a Java String array to JavaScript


    Another way of doing this is by generating the javascript string array in
    the JSP.

    An example code snippet for doing this in a JSP is:

    <script language="javascipt">
    <!--
    Var jsStrArray = new Array();

    <%
    for (int i=0; i < 10; i++) {
    out.println(" jsStrArray[" + i + "]=" + javaStrArray[i]);
    }
    %>

    //-- Now do something useful with the Javascript array jsArray
    //-->
    </script>


    Cheers,

    Rajeev


    "Bronwyn Streeter" <bronwyn@digitalzoo.com.au> wrote:
    >You could possibly place the array in a cookie. That way they can both
    >access it.
    >
    >Gugo <gugo46@hotmail.com> wrote in message
    >news:3c03f1b3$1@147.208.176.211...
    >
    >Hi,
    >
    >This might not be the right discussion forum (it was either this or Java),
    >but I need to pass a String array from Java (JSP) to JavaScript...
    >
    >Any ideas?
    >
    >Thanks in advance.
    >
    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center