Thread: Javascript help

    #1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Posts
    8
    Rep Power
    0

    Javascript help


    Hi All,
    Can I access a javascript variable into my JSP code.

    Iam using

    function x()
    {
    var xy =0;
    <%

    System.out.println("TEST" +xy);

    %>


    }

    I get an error : undefined variable xy

    Can someone suggest an idea on how to do this

    Thanks
  2. #2
  3. Wiser? Not exactly.
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    May 2001
    Location
    Bonita Springs, FL
    Posts
    5,953
    Rep Power
    4033
    JSP would run before the javascript, so no, you can't do that. You can go the other way though, JSP variable -> Javascript variable.

    If you want to send a Javascript variable to JSP, then reload the page w/ it in the query string. eg:

    <script type="text/javascript">
    <!--
    window.location.href=window.location.href+'?res='+screen.width+'x'+screen.height;
    //-->
    </script>

    Use JSP to decided if you need to output that javascript code.

IMN logo majestic logo threadwatch logo seochat tools logo