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

    Join Date
    Oct 2002
    Posts
    1
    Rep Power
    0

    Accessing Javascript Variables from JSP


    I am using some JSP code in a web page which accesses a JavaBean and is returned some value.
    I need to be able to get the selected value from a select (list) and pass this to the JavaBean which will return a Vector of Objects I can use to display.

    The problem is getting the selected value from the list to the JSP code which calls the bean.
    I can use JavaScript to get the value, but then I have no way to get that to the JSP code.
    Is there any way to set a session value using Javascript, so then i could get it back in the JSP?

    any suggestions?

    the code looks something like this:
    <script>
    funciont doSomething(value){
    <%
    Vector cour = admin.getCoursesInDept("THIS IS WHERE I NEED THE JAVASCRIPT VALUE");
    ...

    %>
    }
    </script>
  2. #2
  3. No Profile Picture
    Moderator =(8^(|)
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2002
    Location
    Sacramento, CA
    Posts
    1,710
    Rep Power
    14
    You're getting the value from the form, yes? Form values are accessible from the request object, referenced by the name attribute. So a select list with name="department" would be accessed with:
    Code:
    request.getParameter( "department" );

IMN logo majestic logo threadwatch logo seochat tools logo