DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 3 of 3
  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.
    >
    >



Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links